Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Custom Auth User Model and resetting Migrations

Tags:

django

I'm trying to set a custom AUTH_USER_MODEL in my settings but it throws me a CircularDependencyError due to some past migrations. (I used the regular User before)

How can I fix this? I don't care about the database it's just a single test object. But can I reset/remove the migrations or do I need to start a whole new project?

like image 883
user3199840 Avatar asked Oct 24 '25 14:10

user3199840


1 Answers

Django warns against changing AUTH_USER_MODEL in the docs:

Changing AUTH_USER_MODEL has a big effect on your database structure. It changes the tables that are available, and it will affect the construction of foreign keys and many-to-many relationships. If you intend to set AUTH_USER_MODEL, you should set it before creating any migrations or running manage.py migrate for the first time.

Changing this setting after you have tables created is not supported by makemigrations and will result in you having to manually fix your schema, port your data from the old user table, and possibly manually reapply some migrations.

If you don't care about the database, then I would try dropping the database, deleting your existing migrations files and running makemigrations again.

like image 135
Alasdair Avatar answered Oct 26 '25 10:10

Alasdair



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!