I redefined the User model:
class Profile(AbstractUser): class Meta: ordering = ['id'] verbose_name = u'человека' verbose_name_plural = u'Люди' I registered it in settings.py :
AUTH_USER_MODEL = 'main.Profile' where main is the name of my application.
In admin.py :
from .models import Profile admin.site.register(Profile) And in general, everything worked fine, tested. Filled with test users. The problem appeared after I added the models for the dialogue in the new dialogue.py file to the subfolders of the models my project (along with __init__.py )
from django.db import models from main.models import Profile class Dialogue(models.Model): Partakers = models.ManyToManyField(Profile) class Message(models.Model): Sender = models.ForeignKey(Profile) Mistake:
(hello) D:\django\site\hello>d: & cd D:\django\hello\Scripts & activate.bat & cd D:\django\site\hello & python manage.py runserver Unhandled exception in thread started by <function wrapper at 0x02B93B70> Traceback (most recent call last): File "D:\django\hello\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper fn(*args, **kwargs) File "D:\django\hello\lib\site-packages\django\core\management\commands\runser ver.py", line 116, in inner_run autoreload.raise_last_exception() File "D:\django\hello\lib\site-packages\django\utils\autoreload.py", line 251, in raise_last_exception six.reraise(*_exception) File "D:\django\hello\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper fn(*args, **kwargs) File "D:\django\hello\lib\site-packages\django\__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "D:\django\hello\lib\site-packages\django\apps\registry.py", line 116, in populate app_config.ready() File "D:\django\hello\lib\site-packages\django\contrib\admin\apps.py", line 23 , in ready self.module.autodiscover() File "D:\django\hello\lib\site-packages\django\contrib\admin\__init__.py", lin e 26, in autodiscover autodiscover_modules('admin', register_to=site) File "D:\django\hello\lib\site-packages\django\utils\module_loading.py", line 50, in autodiscover_modules import_module('%s.%s' % (app_config.name, module_to_search)) File "c:\python27\Lib\importlib\__init__.py", line 37, in import_module __import__(name) File "D:\django\hello\lib\site-packages\django\contrib\auth\admin.py", line 7, in <module> from django.contrib.auth.forms import ( File "D:\django\hello\lib\site-packages\django\contrib\auth\forms.py", line 22 , in <module> UserModel = get_user_model() File "D:\django\hello\lib\site-packages\django\contrib\auth\__init__.py", line 199, in get_user_model "AUTH_USER_MODEL refers to model '%s' that has not been installed" % setting s.AUTH_USER_MODEL django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'ma in.Profile' that has not been installed Models deleted. Then he deleted the file. Restarted the runserver, but the error remains
I found a similar problem on the web, but I still don’t understand how to fix it.