One more note... I deleted the database and migrations and started clean again, and this time when I opened the migration file it had setting.AUTH_USER_MODEL the way I wanted it. So I don't know why it didn't do that before.
On Monday, October 11, 2021 at 9:17:39 AM UTC-4 bnmng wrote: > That's genius, David. Thank you! > > On Sunday, October 10, 2021 at 5:56:07 PM UTC-4 David Nugent wrote: > >> Why not just edit the migration file directly and substitute >> 'my_custom..' for settings.AUTH_USER_MODEL? >> >> There should be no problem in doing that. >> >> Regards, David >> >> On Sun, Oct 10, 2021 at 3:02 AM bnmng <[email protected]> wrote: >> >>> Django "strongly recommends" you create custom user, and in your apps >>> you can refer to the custom user with "settings.AUTH_USER_MODEL" or with >>> get_user_model(). >>> >>> Here's the problem. If you develop an app which refers to the custom >>> user, the migrations won't be portable because even if you use the >>> above references, the migration will use the app name and model name of the >>> custom user. >>> >>> Here's what a migration might look like: >>> >>> dependencies = [ >>> ('my_custom_auth_app', '0001_initial'), >>> ] >>> >>> operations = [ >>> migrations.AddField( >>> model_name='mymodel', >>> name='created_by', >>> field=models.ForeignKey( >>> on_delete=django.db.models.deletion.CASCADE, >>> to='my_custom_auth_app.my_custom_user', >>> ), >>> ), >>> ] >>> >>> Even though I never put "my_custom_auth_app" or "my_custom_user" in the >>> app, it translated settings.AUTH_USER_MODEL to the app name and model for >>> the migration. >>> >>> Is there any way to get around this and make your app with its >>> migrations portable? >>> >>> -- >>> >> You received this message because you are subscribed to the Google Groups >>> "Django users" 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-users/8cad467d-5fcc-4d22-9915-64290a1bc9a7n%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/django-users/8cad467d-5fcc-4d22-9915-64290a1bc9a7n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- You received this message because you are subscribed to the Google Groups "Django users" 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-users/0cc78e3d-0d30-40de-8882-f88a8cd46956n%40googlegroups.com.

