diff options
| author | swatantra <swatantra.kumar8@gmail.com> | 2019-06-26 11:44:47 +0530 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-07-04 08:22:56 +0200 |
| commit | 7d52d056e370734f3938d7cf3ab30e06205f1f85 (patch) | |
| tree | 2abeca6c26e28fb4096c00fda7e73c154a0b0d39 /docs | |
| parent | b6d8957356fd7f23e806c65657a72f7316d66b61 (diff) | |
[2.2.x] Fixed #28667 -- Clarified how to override list of forms fields for custom UserAdmin with a custom user model.
Backport of c13e3715f5f46f2ee4ddba357e2589a45e831813 from master
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/topics/auth/customizing.txt | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/docs/topics/auth/customizing.txt b/docs/topics/auth/customizing.txt index fd723cbb94..ce4c1c9edf 100644 --- a/docs/topics/auth/customizing.txt +++ b/docs/topics/auth/customizing.txt @@ -877,6 +877,28 @@ override any of the definitions that refer to fields on ``django.contrib.auth.models.AbstractUser`` that aren't on your custom user class. +.. note:: + + If you are using a custom ``ModelAdmin`` which is a subclass of + ``django.contrib.auth.admin.UserAdmin``, then you need to add your custom + fields to ``fieldsets`` (for fields to be used in editing users) and to + ``add_fieldsets`` (for fields to be used when creating a user). For + example:: + + from django.contrib.auth.admin import UserAdmin + + class CustomUserAdmin(UserAdmin): + ... + fieldsets = UserAdmin.fieldsets + ( + (None, {'fields': ('custom_field',)}), + ) + add_fieldsets = UserAdmin.add_fieldsets + ( + (None, {'fields': ('custom_field',)}), + ) + + See :ref:`a full example <custom-users-admin-full-example>` for more + details. + Custom users and permissions ---------------------------- @@ -962,6 +984,8 @@ If your project uses proxy models, you must either modify the proxy to extend the user model that's in use in your project, or merge your proxy's behavior into your :class:`~django.contrib.auth.models.User` subclass. +.. _custom-users-admin-full-example: + A full example -------------- |
