#16929: Document how to extend UserAdmin with extra profile information
-------------------------------+------------------------------------
     Reporter:  jasper@…       |                    Owner:  nobody
         Type:  New feature    |                   Status:  new
    Component:  Documentation  |                  Version:  1.3
     Severity:  Normal         |               Resolution:
     Keywords:  auth, admin    |             Triage Stage:  Accepted
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+------------------------------------

Comment (by charettes):

 Replying to [comment:3 schinckel]:
 > One issue with this is that if you had two apps that both attempted to
 add something (like an inline) to the UserAdmin, only one of them (the
 last in INSTALLED_APPS?) would take.

 This might feel a bit hackish but you can do the following:
 {{{
 #!python
 #my_nth_app/admin.py

 from django.contrib import admin
 from django.contrib.auth.admin import UserAdmin
 from django.contrib.auth.models import User

 from my_nth_app.models import MyNthAppModel

 class OneOfMyNthAppInline(admin.TabularInline):
     model = MyNthAppModel
     fk_name = 'user'

 #hackish
 RegisteredUserAdmin = admin.site._registry.get(User)

 class MyNthAppUserAdmin(RegisteredUserAdmin):
     inlines = RegisteredUserAdmin.inlines + [OneOfMyNthAppInline]

 # Re-register UserAdmin
 admin.site.unregister(User)
 admin.site.register(User, MyNthAppUserAdmin)
 }}}

 I know tickets aren't the right place to provide such examples but since
 it's the only way (I'm aware of) to achieve what @schinckel was trying to
 do without coupling all the apps I think it was worth posting until a
 proper solution can be documented.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16929#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to