Skip to content

Commit

Permalink
Added a cookbook entry for altering the django admin.
Browse files Browse the repository at this point in the history
Closes django-tastypie#189

Thanks for participating in the issue:
miratcan (Mirat Can Bayrak)
derks (BJ Dierkes)
alextreme
mgan59 (Morgan Craft)
goodwinb (Ben Goodwin)
llonchj (Jordi Llonch)
  • Loading branch information
Issac Kelly committed Jun 4, 2012
1 parent 552aadf commit 96b7f60
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/cookbook.rst
Expand Up @@ -355,3 +355,26 @@ of syntax additional to the default URL scheme::
wrapped_view = super(UserResource, self).wrap_view(view)
return wrapped_view(request, *args, **kwargs)
return wrapper

Adding to the Django Admin
--------------------------

If you're using the django admin and ApiKeyAuthentication, you may want to see
or edit ApiKeys next to users. To do this, you need to unregister the built-in
UserAdmin, alter the inlines, and re-register it. This could go in any of your
admin.py files. You may also want to register ApiAccess and ApiKey models on
their own.::

from tastypie.admin import ApiKeyInline
from tastypie.models import ApiAccess, ApiKey
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User

admin.site.register(ApiKey)
admin.site.register(ApiAccess)

class UserModelAdmin(UserAdmin):
inlines = UserAdmin.inlines + [ApiKeyInline]

admin.site.unregister(User)
admin.site.register(User,UserModelAdmin)

0 comments on commit 96b7f60

Please sign in to comment.