Skip to content
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

Extending AbstractUser fails to import AbstractUser #177

Open
clarson99 opened this issue Mar 11, 2023 · 3 comments
Open

Extending AbstractUser fails to import AbstractUser #177

clarson99 opened this issue Mar 11, 2023 · 3 comments

Comments

@clarson99
Copy link

When you create a model that extends AbstractUser there 2 issues:

  1. The resulting models.py is missing from django.contrib.auth.models import AbstractUser.
  2. settings.py is missing something like this AUTH_USER_MODEL = 'users.user'

This causes migrations to fail.

image

@mmcardle
Copy link
Owner

@clarson99

Thanks for the feedback.

  1. Should be an easy fix, will try to get that updated.
  2. This is slightly more work as a project may have multiple models that could be a AUTH_USER_MODEL there will need to be a way of indicating which one.

@clarson99
Copy link
Author

clarson99 commented Mar 15, 2023

For number 2, would this be a reasonable work around?

  1. If there is only one user model
    a. choose it by adding AUTH_USER_MODEL = 'users.user'

  2. if there are multiple user models
    a. add a comment like '# TODO there were multiple user models found, we chose the first one, please uncomment the appropriate model`

    b. add the first model by adding AUTH_USER_MODEL = 'users.user'

    c. add the remaining models, but comment them out like: # AUTH_USER_MODEL = 'users2.user2'

This would at least leave a clue about what is happening, it would ensure the app starts and runs without errors, and lastly you would have to add confusing features to the UI.

@mmcardle
Copy link
Owner

Issue 1 should now be fixed and deployed to djangobuilder.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants