-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom user model #2015
Merged
Merged
Add custom user model #2015
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1b5170e
to
914a11a
Compare
914a11a
to
b870fda
Compare
shanbady
requested changes
Feb 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting this error when trying to run show migrations
Traceback (most recent call last):
File "/opt/venv/lib/python3.12/site-packages/django/apps/config.py", line 235, in get_model
return self.models[model_name.lower()]
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
KeyError: 'user'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/venv/lib/python3.12/site-packages/django/contrib/auth/__init__.py", line 170, in get_user_model
return django_apps.get_model(settings.AUTH_USER_MODEL, require_ready=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/venv/lib/python3.12/site-packages/django/apps/registry.py", line 213, in get_model
return app_config.get_model(model_name, require_ready=require_ready)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/venv/lib/python3.12/site-packages/django/apps/config.py", line 237, in get_model
raise LookupError(
LookupError: App 'users' doesn't have a 'User' model.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/src/./manage.py", line 29, in <module>
execute_from_command_line(sys.argv)
File "/opt/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/opt/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 416, in execute
django.setup()
File "/opt/venv/lib/python3.12/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/opt/venv/lib/python3.12/site-packages/django/apps/registry.py", line 116, in populate
app_config.import_models()
File "/opt/venv/lib/python3.12/site-packages/django/apps/config.py", line 269, in import_models
self.models_module = import_module(models_module_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/src/profiles/models.py", line 49, in <module>
User = get_user_model()
^^^^^^^^^^^^^^^^
File "/opt/venv/lib/python3.12/site-packages/django/contrib/auth/__init__.py", line 176, in get_user_model
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'users.User' that has not been installed
b870fda
to
2d912b4
Compare
shanbady
approved these changes
Feb 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
NOTE: #2013 should be reviewed first, as changes from it are included here.
What are the relevant tickets?
Part of https://github.com/mitodl/hq/issues/6679
Description (What does it do?)
This adds a custom user model and points the
AUTH_USER_MODEL
to it.It updates the implementation of the
0001_initial.py
model by having deleted this file and then recreating it after updatingAUTH_USER_MODEL
.How can this be tested?
0001_initial.py
gets recorded as having been run. If it's been merged, you can just go ahead and run the migration offmain
../manage.py showmigrations
still lists0001_initial.py
under the users app as having been applied../manage.py makemigrations --dry
and verify there are no changes.When you are done with testing, be sure to run
./manage.py migrate users 0001
to revert not break things on other branches.