--
Ticket URL: <https://code.djangoproject.com/ticket/28757>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
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>
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>
* 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>
* owner: nobody => hui shang
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/28757#comment:4>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/28757#comment:5>
* 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>
* 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>
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>
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>
* 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>
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>
* 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>