You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a Django project, if I can import the abstract models, I should also be able to import the abstract forms. I can also see instances where extending the UserFactory class could be useful. To provide the greatest flexibility, this project should use Django's get_user_model() function in all locations where it needs to reference the User model.
Actual Behavior
Just as Issue #36 described an inability to import the mix-in model classes without needing to add improved_user to INSTALLED_APPS, the same error occurs when attempting to import AbstractUserCreationForm or AbstractUserChangeForm or attempting to extend the UserCreationForm or UserChangeForm classes.
The moment forms.py is loaded, the following error occurs:
File "/Users/user/ttt/.venv/lib/python3.6/site-packages/improved_user/forms.py", line 7, in <module>
from .models import User
File "/Users/user/ttt/.venv/lib/python3.6/site-packages/improved_user/models.py", line 12, in <module>
class User(AbstractUser):
File "/Users/user/ttt/.venv/lib/python3.6/site-packages/django/db/models/base.py", line 118, in __new__
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class improved_user.models.User doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
For the record, the offending line of code also exists in your factories.py, and causes the same error when imported. If UserFactory is intended to be available for import/extending, then the fix will have to be applied to both files.
Context
In my project, I am already importing AbstractBaseUser in order to add more fields. To also provide a custom UserAdmin class to show all my extra user model fields, I included the following in my admin.py:
from improved_user.forms import UserCreationForm, UserChangeForm
from .models import User
class UserAdmin(BaseUserAdmin):
# The forms to add and change user instances
add_form = UserCreationForm
form = UserChangeForm
The import above causes the error.
Steps to Reproduce the Problem
Create a new Django project with a new Django app.
Run pip install git+https://github.com/jambonsw/django-improved-user.git.
Include the sample code above.
Run a Django check to trigger the error.
The text was updated successfully, but these errors were encountered:
Specifications
Expected Behavior
In a Django project, if I can import the abstract models, I should also be able to import the abstract forms. I can also see instances where extending the
UserFactory
class could be useful. To provide the greatest flexibility, this project should use Django'sget_user_model()
function in all locations where it needs to reference the User model.Actual Behavior
Just as Issue #36 described an inability to import the mix-in model classes without needing to add
improved_user
toINSTALLED_APPS
, the same error occurs when attempting to importAbstractUserCreationForm
orAbstractUserChangeForm
or attempting to extend theUserCreationForm
orUserChangeForm
classes.The moment
forms.py
is loaded, the following error occurs:For the record, the offending line of code also exists in your
factories.py
, and causes the same error when imported. If UserFactory is intended to be available for import/extending, then the fix will have to be applied to both files.Context
In my project, I am already importing
AbstractBaseUser
in order to add more fields. To also provide a customUserAdmin
class to show all my extra user model fields, I included the following in myadmin.py
:The import above causes the error.
Steps to Reproduce the Problem
pip install git+https://github.com/jambonsw/django-improved-user.git
.check
to trigger the error.The text was updated successfully, but these errors were encountered: