Saturday, October 9, 2021

When you app depends on a custom user model

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 = [

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
To view this discussion on the web visit

No comments:

Post a Comment