It seems like the password related methods are not available on the User
object, only in the default manager, which I gather is not available in
migrations. Is this intentional?
--
Ticket URL: <https://code.djangoproject.com/ticket/26445>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* Attachment "set_password_user_migration.zip" added.
Test project with failing migration dependent on contrib.auth
* owner: nobody => giuliettamasina
* needs_better_patch: => 0
* status: new => assigned
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/26445#comment:1>
* status: assigned => closed
* resolution: => invalid
Comment:
It is expected behaviour that these methods are not available in your
migrations. The reason is shortly explained in
[https://docs.djangoproject.com/en/1.9/topics/migrations/#historical-
models Historical models]: arbitrary code can't be serialized, so there is
no general way to make the historical methods available in your
migrations.
To avoid this problem you can use the `make_password` function directly
and set the hashed password on your user:
{{{
from django.contrib.auth.hashers import make_password
user.password = make_password('password')
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26445#comment:2>
* cc: MarkusH (added)
Comment:
Was it a mistake to add `use_in_migrations = True` to the `UserManager` if
it's not actually usable?
--
Ticket URL: <https://code.djangoproject.com/ticket/26445#comment:3>
* status: closed => new
* needs_better_patch: 0 => 1
* component: Migrations => contrib.auth
* has_patch: 0 => 1
* resolution: invalid =>
* stage: Unreviewed => Accepted
Comment:
Reopening per [https://github.com/django/django/pull/6578 Markus's PR] to
solve this.
--
Ticket URL: <https://code.djangoproject.com/ticket/26445#comment:4>
* cc: django2.20.orzelf@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/26445#comment:5>
* keywords: => 2.0
--
Ticket URL: <https://code.djangoproject.com/ticket/26445#comment:6>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/26445#comment:6>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"7af8f4127397279d19ef7c7899e93018274e2f9b" 7af8f41]:
{{{
#!CommitTicketReference repository=""
revision="7af8f4127397279d19ef7c7899e93018274e2f9b"
Refs #26445 -- Allowed using UserManager.create_user()/create_superuser()
in migrations.
Used app config to lookup user model in _create_user().
Thanks Markus Holtermann for the review and initial patch.
Thanks Simon Charette for the implementation idea.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26445#comment:7>
* status: new => closed
* resolution: => fixed
--
Ticket URL: <https://code.djangoproject.com/ticket/26445#comment:8>