#25313: Document how to migrate from a built-in User model to a custom User
model
-------------------------------+------------------------------------
Reporter: Carl Meyer | Owner: nobody
Type: New feature | Status: new
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Comment (by David Freiholtz):
With reservation for that I'm still pretty much a beginner and that I only
tried it on a small project.
I had great help to migrate from a built-in User model to a custom User
model from this page:
https://code.djangoproject.com/ticket/25313
And this one https://simpleisbetterthancomplex.com/article/2021/07/08
/what-you-should-know-about-the-django-user-model.html
Then I wrote up a short bullet list on how to do it on my django based
mastodon
https://freiholtz.net/@[email protected]/posts/159869836921574712/
TL;DR
First, only use get_user_model in your code
1. Create a datadump python manage.py dumpdata > datadump.json
2. Create the new user model and set db_table = 'auth_user' in Meta
section.
3. Truncate the database
4. python manage.py makemigrations
5. python manage.py migrate
6. Edit {"model": "auth.user" to {"model": "myapp.customuser" in
datadump.json
7. python manage.py loaddata datadump.json
--
Ticket URL: <https://code.djangoproject.com/ticket/25313#comment:30>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070186f46e10c9-a00a8954-0e00-4237-83ad-36094e80a2b1-000000%40eu-central-1.amazonses.com.