django - LookupError: App 'users' doesn't have a 'user' model -
django 1.9.7 i'm using pyenv virtualenv autoenv
i want extend user model so, decide use abstractuser
(abstractuser's class meta
abstract = true, can't make table, inheritance class can make table, right??)
anyways
(wef project name) make app wef/users/models/__init__.py
from .user import user
in wef/users/models/user.py
from django.contrib.auth.models import abstractuser django.db import models class user(abstractuser): phonenumber = models.charfield( max_length = 11, blank = true, null = true )
and add users
app in settings.py
installed_apps = [ [...] 'users', ] auth_user_model = 'users.user'
so, think when makemigrations, migrate
django make model table user...
python wef/manage.py makemigrations users
it shows error
traceback (most recent call last): file "/users/hanminsoo/.pyenv/versions/study_alone/lib/python3.5/site-packages/django/apps/config.py", line 163, in get_model return self.models[model_name.lower()] keyerror: 'user' during handling of above exception, exception occurred: traceback (most recent call last): file "manage.py", line 10, in <module> execute_from_command_line(sys.argv) file "/users/hanminsoo/.pyenv/versions/study_alone/lib/python3.5/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() file "/users/hanminsoo/.pyenv/versions/study_alone/lib/python3.5/site-packages/django/core/management/__init__.py", line 345, in execute self.fetch_command(subcommand).run_from_argv(self.argv) file "/users/hanminsoo/.pyenv/versions/study_alone/lib/python3.5/site-packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) file "/users/hanminsoo/.pyenv/versions/study_alone/lib/python3.5/site-packages/django/core/management/base.py", line 398, in execute self.check() file "/users/hanminsoo/.pyenv/versions/study_alone/lib/python3.5/site-packages/django/core/management/base.py", line 426, in check include_deployment_checks=include_deployment_checks, file "/users/hanminsoo/.pyenv/versions/study_alone/lib/python3.5/site-packages/django/core/checks/registry.py", line 75, in run_checks new_errors = check(app_configs=app_configs) file "/users/hanminsoo/.pyenv/versions/study_alone/lib/python3.5/site-packages/django/contrib/auth/checks.py", line 12, in check_user_model cls = apps.get_model(settings.auth_user_model) file "/users/hanminsoo/.pyenv/versions/study_alone/lib/python3.5/site-packages/django/apps/registry.py", line 197, in get_model return self.get_app_config(app_label).get_model(model_name.lower()) file "/users/hanminsoo/.pyenv/versions/study_alone/lib/python3.5/site-packages/django/apps/config.py", line 166, in get_model "app '%s' doesn't have '%s' model." % (self.label, model_name)) lookuperror: app 'users' doesn't have 'user' model.
i can't understand why django can't found users.user model
and when change `auth_user_model=useraaa'
it show error (capital letters changed lower case)
lookuperror: app 'users' doesn't have 'useraaa' model.
i can not find problem please me.. ㅠ_ㅠ
i think have created database schema. django documentation:
changing auth_user_model has big effect on database structure. changes tables available, , affect construction of foreign keys , many-to-many relationships. if intend set auth_user_model, should set before creating migrations or running manage.py migrate first time.
changing setting after have tables created not supported makemigrations , result in having manually fix schema, port data old user table, , possibly manually reapply migrations.
Comments
Post a Comment