[Django] #28757: Using forms of contrib.auth without installing contrib.auth

16 views
Skip to first unread message

Django

unread,
Oct 31, 2017, 12:47:00 AM10/31/17
to django-...@googlegroups.com
#28757: Using forms of contrib.auth without installing contrib.auth
-----------------------------------------+---------------------------------
Reporter: Sagar Chalise | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: 1.11
Severity: Normal | Keywords: auth forms apps
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+---------------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/28757>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 31, 2017, 11:50:29 AM10/31/17
to django-...@googlegroups.com
#28757: Using forms of contrib.auth without installing contrib.auth
---------------------------------+--------------------------------------

Reporter: Sagar Chalise | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: 1.11
Severity: Normal | Resolution:

Keywords: auth forms apps | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by Tim Graham):

Which forms are you trying to use and what error do you get?

--
Ticket URL: <https://code.djangoproject.com/ticket/28757#comment:1>

Django

unread,
Oct 31, 2017, 10:59:27 PM10/31/17
to django-...@googlegroups.com
#28757: Using forms of contrib.auth without installing contrib.auth
---------------------------------+--------------------------------------

Reporter: Sagar Chalise | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: 1.11
Severity: Normal | Resolution:

Keywords: auth forms apps | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by Sagar Chalise):

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/28757#comment:2>

Django

unread,
Nov 1, 2017, 3:38:35 PM11/1/17
to django-...@googlegroups.com
#28757: Allow using forms of contrib.auth without installing contrib.auth
--------------------------------------+------------------------------------

Reporter: Sagar Chalise | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.auth | Version: 1.11
Severity: Normal | Resolution:
Keywords: auth forms apps | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted
* type: New feature => Cleanup/optimization


Comment:

I wonder if moving that import inside the form class where it's used would
be feasible and solve the issue.

--
Ticket URL: <https://code.djangoproject.com/ticket/28757#comment:3>

Django

unread,
Nov 13, 2017, 4:01:56 AM11/13/17
to django-...@googlegroups.com
#28757: Allow using forms of contrib.auth without installing contrib.auth
-------------------------------------+-------------------------------------
Reporter: Sagar Chalise | Owner: hui shang
Type: | Status: assigned
Cleanup/optimization |
Component: contrib.auth | Version: 1.11
Severity: Normal | Resolution:
Keywords: auth forms apps | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by hui shang):

* owner: nobody => hui shang
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/28757#comment:4>

Django

unread,
Nov 17, 2017, 12:03:46 AM11/17/17
to django-...@googlegroups.com
#28757: Allow using forms of contrib.auth without installing contrib.auth
-------------------------------------+-------------------------------------
Reporter: Sagar Chalise | Owner: hui shang
Type: | Status: assigned
Cleanup/optimization |
Component: contrib.auth | Version: 1.11
Severity: Normal | Resolution:
Keywords: auth forms apps | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by hui shang):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/28757#comment:5>

Django

unread,
Jan 5, 2018, 3:06:53 PM1/5/18
to django-...@googlegroups.com
#28757: Allow using forms of contrib.auth without installing contrib.auth
-------------------------------------+-------------------------------------
Reporter: Sagar Chalise | Owner:
Type: | shangdahao
Cleanup/optimization | Status: closed
Component: contrib.auth | Version: 1.11
Severity: Normal | Resolution: fixed
Keywords: auth forms apps | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"3333d935d2914cd80cf31f4803821ad5c0e2a51d" 3333d93]:
{{{
#!CommitTicketReference repository=""
revision="3333d935d2914cd80cf31f4803821ad5c0e2a51d"
Fixed #28757 -- Allowed using contrib.auth forms without installing
contrib.auth.

Also fixed #28608 -- Allowed UserCreationForm and UserChangeForm to
work with custom user models.

Thanks Sagar Chalise and Rômulo Collopy for reports, and Tim Graham
and Tim Martin for reviews.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28757#comment:6>

Django

unread,
Jan 13, 2018, 8:42:27 PM1/13/18
to django-...@googlegroups.com
#28757: Allow using forms of contrib.auth without installing contrib.auth
-------------------------------------+-------------------------------------
Reporter: Sagar Chalise | Owner:
Type: | shangdahao
Cleanup/optimization | Status: new
Component: contrib.auth | Version: 1.11
Severity: Normal | Resolution:
Keywords: auth forms apps | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: closed => new
* has_patch: 1 => 0
* resolution: fixed =>


Comment:

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?

--
Ticket URL: <https://code.djangoproject.com/ticket/28757#comment:7>

Django

unread,
Jan 24, 2018, 7:23:30 PM1/24/18
to django-...@googlegroups.com
#28757: Allow using forms of contrib.auth without installing contrib.auth
-------------------------------------+-------------------------------------
Reporter: Sagar Chalise | Owner:
Type: | shangdahao
Cleanup/optimization | Status: new
Component: contrib.auth | Version: 1.11
Severity: Normal | Resolution:
Keywords: auth forms apps | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/28757#comment:8>

Django

unread,
May 26, 2018, 11:30:50 AM5/26/18
to django-...@googlegroups.com
#28757: Allow using forms of contrib.auth without installing contrib.auth
-------------------------------------+-------------------------------------
Reporter: Sagar Chalise | Owner:
Type: | shangdahao
Cleanup/optimization | Status: new
Component: contrib.auth | Version: 1.11
Severity: Normal | Resolution:
Keywords: auth forms apps | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Sławek Ehlert):

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).

--
Ticket URL: <https://code.djangoproject.com/ticket/28757#comment:9>

Django

unread,
Jul 2, 2018, 6:57:23 PM7/2/18
to django-...@googlegroups.com
#28757: Allow using forms of contrib.auth without installing contrib.auth
-------------------------------------+-------------------------------------
Reporter: Sagar Chalise | Owner:
Type: | shangdahao
Cleanup/optimization | Status: closed
Component: contrib.auth | Version: 1.11
Severity: Normal | Resolution: fixed
Keywords: auth forms apps | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"f3fa86a89b3b85242f49b2b9acf58b5ea35acc1f" f3fa86a]:
{{{
#!CommitTicketReference repository=""
revision="f3fa86a89b3b85242f49b2b9acf58b5ea35acc1f"
Fixed #29449 -- Reverted "Fixed #28757 -- Allowed using contrib.auth forms
without installing contrib.auth."

This reverts commit 3333d935d2914cd80cf31f4803821ad5c0e2a51d due to
a crash if USERNAME_FIELD isn't a CharField.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28757#comment:10>

Django

unread,
Jul 2, 2018, 7:04:47 PM7/2/18
to django-...@googlegroups.com
#28757: Allow using forms of contrib.auth without installing contrib.auth
-------------------------------------+-------------------------------------
Reporter: Sagar Chalise | Owner:
Type: | shangdahao
Cleanup/optimization | Status: closed
Component: contrib.auth | Version: 1.11
Severity: Normal | Resolution: fixed
Keywords: auth forms apps | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"78f502cd0bc834422c3f189e852564fe4b6459f2" 78f502c]:
{{{
#!CommitTicketReference repository=""
revision="78f502cd0bc834422c3f189e852564fe4b6459f2"
[2.1.x] Fixed #29449 -- Reverted "Fixed #28757 -- Allowed using


contrib.auth forms without installing contrib.auth."

This reverts commit 3333d935d2914cd80cf31f4803821ad5c0e2a51d due to
a crash if USERNAME_FIELD isn't a CharField.

Backport of f3fa86a89b3b85242f49b2b9acf58b5ea35acc1f from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28757#comment:11>

Django

unread,
Jul 2, 2018, 7:14:12 PM7/2/18
to django-...@googlegroups.com
#28757: Allow using forms of contrib.auth without installing contrib.auth
-------------------------------------+-------------------------------------
Reporter: Sagar Chalise | Owner:
Type: | shangdahao
Cleanup/optimization | Status: new
Component: contrib.auth | Version: 1.11
Severity: Normal | Resolution:
Keywords: auth forms apps | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: closed => new

* resolution: fixed =>


Comment:

I reverted the original patch due to the regression described in #29449.
Unit tests for those cases are provided in
[https://github.com/django/django/pull/10020 PR 10020] which can be
included in the patch for this ticket.

--
Ticket URL: <https://code.djangoproject.com/ticket/28757#comment:12>

Django

unread,
Mar 18, 2024, 2:52:19 AMMar 18
to django-...@googlegroups.com
#28757: Allow using forms of contrib.auth without installing contrib.auth
-------------------------------------+-------------------------------------
Reporter: Sagar Chalise | Owner:
Type: | shangdahao
Cleanup/optimization | Status: new
Component: contrib.auth | Version: 1.11
Severity: Normal | Resolution:
Keywords: auth forms apps | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ülgen Sarıkavak):

* cc: Ülgen Sarıkavak (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/28757#comment:13>
Reply all
Reply to author
Forward
0 new messages