Opened 7 years ago
Last modified 9 months ago
#28757 new Cleanup/optimization
Allow using forms of contrib.auth without installing contrib.auth
Reported by: | Sagar Chalise | Owned by: | shangdahao |
---|---|---|---|
Component: | contrib.auth | Version: | 1.11 |
Severity: | Normal | Keywords: | auth forms apps |
Cc: | Ülgen Sarıkavak | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
It seems the forms available in contrib.auth app cannot be used without using contrib.auth in settings.INSTALLED_APPS.
May be break some of reusable feature of forms into base_forms.py just like AbstractBaseUser model.
Change History (13)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Basically, I am using custom user model which avoids both groups and permissions. I could easily use Authentication as well as Password related forms but seems the forms.py directly imports User from contrib.auth.models https://github.com/django/django/blob/master/django/contrib/auth/forms.py#L10. Which seems to enforce me to install contrib.auth package.
comment:3 by , 7 years ago
Summary: | Using forms of contrib.auth without installing contrib.auth → Allow using forms of contrib.auth without installing contrib.auth |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | New feature → Cleanup/optimization |
I wonder if moving that import inside the form class where it's used would be feasible and solve the issue.
comment:4 by , 7 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:7 by , 7 years ago
Has patch: | unset |
---|---|
Resolution: | fixed |
Status: | closed → new |
After this commit, there are some errors when running $ ./tests/runtests.py auth_tests.test_management
(but adding --reverse
fixes it). shangdahao, can you debug that?
comment:8 by , 7 years ago
I tried to solve the issue by putting the reload of django.contrib.auth.forms
in django.test.signals.user_model_swapped()
rather than limiting it to the Django tests. I couldn't get it to work.
The issue is solved by adding import django.contrib.auth.forms
to the top of auth_tests/test_management.py
but I don't know why that works.
comment:9 by , 7 years ago
Tim, I think the commit from this ticket doesn't properly support all the cases of custom user models (i.e. it assumes that the username field should be a subclass of CharField). I've opened #29449 for that. Also there's something weird going on with running the tests (details are in the ticket).
comment:12 by , 6 years ago
Resolution: | fixed |
---|---|
Status: | closed → new |
comment:13 by , 9 months ago
Cc: | added |
---|
Which forms are you trying to use and what error do you get?