Ticket #16929: 16929.diff

File 16929.diff, 1.8 KB (added by Tim Graham, 12 years ago)
  • docs/topics/auth.txt

    diff --git a/docs/topics/auth.txt b/docs/topics/auth.txt
    index c45e4bb..ef03d54 100644
    a b the handler, if ``created`` is ``True``, create the associated user profile::  
    650650.. seealso:: :doc:`/topics/signals` for more information on Django's signal
    651651    dispatcher.
    652652
     653Adding UserProfile fields to the admin
     654--------------------------------------
     655
     656To add the UserProfile fields to the user page in the admin, define an
     657:class:`~django.contrib.admin.InlineModelAdmin` (for this example, we'll use a
     658:class:`~django.contrib.admin.StackedInline`) in your app's ``admin.py`` and
     659add it to a ``UserAdmin`` class which is registered with the
     660:class:`~django.contrib.auth.models.User` class::
     661
     662    from django.contrib import admin
     663    from django.contrib.auth.admin import UserAdmin
     664    from django.contrib.auth.models import User
     665
     666    from my_user_profile_app.models import UserProfile
     667
     668    # Define an inline admin descriptor for UserProfile model
     669    # which acts a bit like a singleton
     670    class UserProfileInline(admin.StackedInline):
     671        model = UserProfile
     672        can_delete = False
     673        verbose_name_plural = 'profile'
     674
     675    # Define a new User admin
     676    class UserAdmin(UserAdmin):
     677        inlines = (UserProfileInline, )
     678
     679    # Re-register UserAdmin
     680    admin.site.unregister(User)
     681    admin.site.register(User, UserAdmin)
     682
    653683Authentication in Web requests
    654684==============================
    655685
    The login_required decorator  
    948978        (r'^accounts/login/$', 'django.contrib.auth.views.login'),
    949979
    950980    .. versionchanged:: 1.5
    951    
     981
    952982    As of version 1.5 :setting:`settings.LOGIN_URL <LOGIN_URL>` now also accepts
    953983    view function names and :ref:`named URL patterns <naming-url-patterns>`.
    954984    This allows you to freely remap your login view within your URLconf
Back to Top