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/CAE5VhgXFwvTqnBjCiR5%3D-JXDxuc_u0naCMAP%3DJfqF4VCPD59jg%40mail.gmail.com.

