I have a custom user model and integrated the django_registration 2-step activation work flow into the app. The resgitration process is working fine from the app's signup form which I created.
However I am not able to add a User from the admin anymore. When I try to do that I get the following error:
Request Method: | GET
-- | --
http://127.0.0.1:8000/admin/accounts/customuser/add/
2.2
KeyError
'email'
/home/nitin/.local/share/virtualenvs/bookmark-GvaJsEPx/lib/python3.7/site-packages/django_registration/forms.py in __init__, line 59
/home/nitin/.local/share/virtualenvs/bookmark-GvaJsEPx/bin/python
3.7.3
['/home/nitin/Study/Django/myapps/bookmark', '/home/nitin/.local/share/virtualenvs/bookmark-GvaJsEPx/lib/python37.zip', '/home/nitin/.local/share/virtualenvs/bookmark-GvaJsEPx/lib/python3.7', '/home/nitin/.local/share/virtualenvs/bookmark-GvaJsEPx/lib/python3.7/lib-dynload', '/home/nitin/anaconda3/lib/python3.7', '/home/nitin/.local/share/virtualenvs/bookmark-GvaJsEPx/lib/python3.7/site-packages']
Following are my relevant code:
#admin.py
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from accounts.forms import CustomUserCreationForm, CustomUserChangeForm
from accounts.models import CustomUser
class CustomUserAdmin(UserAdmin):
add_form = CustomUserCreationForm
form = CustomUserChangeForm
model = CustomUser
list_display = ['username', 'email', 'age', 'company', 'is_staff']
admin.site.register(CustomUser, CustomUserAdmin)
# forms.py
from django_registration.forms import RegistrationForm
from accounts.models import CustomUser
class CustomUserCreationForm(RegistrationForm):
class Meta(RegistrationForm.Meta):
model = CustomUser
fields = ('username', 'email', 'age', 'company',)
class CustomUserChangeForm(RegistrationForm):
class Meta(RegistrationForm.Meta):
model = CustomUser
fields = ('username', 'email', 'age', 'company',)
#models.py
from django.contrib.auth.models import AbstractUser
from django.db import models
class CustomUser(AbstractUser):
age = models.PositiveIntegerField(null=True, blank=True)
company = models.CharField(max_length=250, blank=True)
This seems to be something wrong with your admin config, not with django-registration. Please try a general Django support channel for help with configuring the Django admin.
I have a custom user model and integrated the django_registration 2-step activation work flow into the app. The resgitration process is working fine from the app's signup form which I created.
However I am not able to add a User from the admin anymore. When I try to do that I get the following error:
Following are my relevant code: