Commit d9a3b179 authored by Florent Chehab's avatar Florent Chehab

feat(custom user model, admin)

* The custom user model previously introduced can now be fully edited in the admin of the site.
parent 6ce40dc9
Pipeline #37944 passed with stages
in 4 minutes and 26 seconds
from rest_framework.authtoken.admin import TokenAdmin
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.forms import UserChangeForm
from rest_framework.authtoken.admin import TokenAdmin
from .models import User, UserAdmin)
# Handling of the registration of the custom User model to make sure
# we can see all the fields.
# taken from:
class CustomUserChangeForm(UserChangeForm):
class Meta(UserChangeForm.Meta):
model = User
class CustomUserAdmin(UserAdmin):
form = CustomUserChangeForm
fieldsets = UserAdmin.fieldsets + (
{"fields": ("allow_sharing_personal_info", "secondary_email", "pseudo")},
), CustomUserAdmin)
# Pour la génération de token dans l'administration du site.
TokenAdmin.raw_id_fields = ("user",)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment