Set AUTH_USER_MODEL from apps inside folder from settings.py

Set AUTH_USER_MODEL from apps inside folder from settings.py



I'm new to django and I'm trying to extend the user class in one of my apps but I'm having trouble redirecting from setting.py to the model that contains my AbstractUser



My Nproject:


-apps:
--profile:
---__init__.py
---apps.py
---forms.py
---models.py
---urls.py
---views.py
--apps1
-media
-static
-templates
-Nproject:
--__init__.py
--settings.py
--urls.py
--wsgi.py



model in apps.profile.models


from django.db import models
from django.contrib.auth.models import AbstractUser

class User(AbstractUser):
address = models.CharField(max_length=255)
def __str__(self):
return '%s %s' % (self.email, self.username)



setting.py and here I think this is my mistake


AUTH_USER_MODEL = 'apps.User' #not working



I think the error is in AUTH_USER_MODEL that I do not know how to properly reference the model User



Research some sites and tell me that you should use the init.py file but it is not working



init in apps.profile


from .models import User



Error:


Traceback (most recent call last):
File "./manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/projects/.virtualenvs/Nproject/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/home/projects/.virtualenvs/Nproject/lib/python3.6/site-packages/django/core/management/__init__.py", line 347, in execute
django.setup()
File "/home/projects/.virtualenvs/Nproject/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/projects/.virtualenvs/Nproject/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "/home/projects/.virtualenvs/Nproject/lib/python3.6/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/home/projects/.virtualenvs/Nproject/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/home/projects/Nproject/apps/perfil/__init__.py", line 1, in <module>
from .models import User
File "/home/projects/Nproject/apps/perfil/models.py", line 2, in <module>
from django.contrib.auth.models import User
File "/home/projects/.virtualenvs/Nproject/lib/python3.6/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/home/projects/.virtualenvs/Nprojects/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "/home/projects/.virtualenvs/Nproject/lib/python3.6/site-packages/django/db/models/base.py", line 100, in __new__
app_config = apps.get_containing_app_config(module)
File "/home/projects/.virtualenvs/Nproject/lib/python3.6/site-packages/django/apps/registry.py", line 244, in get_containing_app_config
self.check_apps_ready()
File "/home/projects/.virtualenvs/Nproject/lib/python3.6/site-packages/django/apps/registry.py", line 127, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.



Additional data:
-Django 2.1
-Python 3.6.5




1 Answer
1



The correct name string for the AUTH_USER_MODEL would be appname.modelname. In your case, I suppose it is 'profile.user' (it could be different if you changed the app name by yourself)


AUTH_USER_MODEL


'profile.user'



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế