Hello,
I have a custom User model as below with Wagtail 1.6.3 and Django
1.10.2. When I attempt to ./manage.py createsuperuser, the
AppRegistryNotReady("Models aren't loaded yet.") exception is thrown.
Here is my code.
########### settings.py
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'compressor',
'taggit',
'modelcluster',
'rest_framework',
'django.contrib.admin',
'wagtail.wagtailcore',
'wagtail.wagtailadmin',
'wagtail.wagtaildocs',
'wagtail.wagtailsnippets',
'wagtail.wagtailusers',
'wagtail.wagtailimages',
'wagtail.wagtailembeds',
'wagtail.wagtailsearch',
'wagtail.wagtailredirects',
'wagtail.wagtailforms',
'wagtail.wagtailsites',
'wagtail.contrib.wagtailapi',
'wagtail.contrib.modeladmin',
'cdssite',
)
AUTH_USER_MODEL = 'cdssite.User'
WAGTAIL_USER_EDIT_FORM = 'users.forms.CustomUserEditForm'
WAGTAIL_USER_CREATION_FORM = 'users.forms.CustomUserCreationForm'
WAGTAIL_USER_CUSTOM_FIELDS = ['customer_name']
########### models.py
from django.db import models
from django import forms
from django.contrib.auth.models import AbstractUser
from wagtail.wagtailusers.forms import UserEditForm, UserCreationForm
class CustomerGroup(models.Model):
name = models.CharField('Group Name', max_length=64, unique=True)
def __str__(self):
return '%s' % (
self.name,)
class Customer(models.Model):
name = models.CharField('Customer Name', max_length=64, unique=True)
customer_group = models.ForeignKey(CustomerGroup, on_delete=models.CASCADE)
list_display = ('get_customer_group',)
def __str__(self):
return '%s' % (
self.name,)
class User(AbstractUser):
customer_name = models.ForeignKey(Customer)
class CustomUserEditForm(UserEditForm):
customer_name = forms.ModelChoiceField(queryset=Customer.objects, required=True)
class CustomUserCreationForm(UserCreationForm):
customer_name = forms.ModelChoiceField(queryset=Customer.objects, required=True)
The create.html and edit.html forms are in
cdssite/templates/wagtailusers/users. What I am trying to accomplish is
having a custom User model with one extra field, customer_name, which is
related to the Customer model. One Customer can have many Users. One
CustomerGroup can have multiple Customers.
Why am I getting the AppRegistryNotReady("Models aren't loaded yet.")
exception?
--
Regards,
Clifford