I'm trying to migrate my custom user model and I run makemigrations
command to make migrations for new models. But when I run migrate command it throws this error :
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency accounts.0001_initial on database 'default'.
Traceback:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\AHMED\anaconda3\envs\dotesrow\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\AHMED\anaconda3\envs\dotesrow\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\AHMED\anaconda3\envs\dotesrow\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\AHMED\anaconda3\envs\dotesrow\lib\site-packages\django\core\management\base.py", line 371, in execute
output = self.handle(*args, **options)
File "C:\Users\AHMED\anaconda3\envs\dotesrow\lib\site-packages\django\core\management\base.py", line 85, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\AHMED\anaconda3\envs\dotesrow\lib\site-packages\django\core\management\commands\migrate.py", line 95, in handle
executor.loader.check_consistent_history(connection)
File "C:\Users\AHMED\anaconda3\envs\dotesrow\lib\site-packages\django\db\migrations\loader.py", line 302, in check_consistent_history
raise InconsistentMigrationHistory(
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency accounts.0001_initial on database
'default'.
models.py
class User(auth.models.AbstractUser):
current_balance = models.IntegerField(("current balance"),default=0,blank=True)
age = models.IntegerField(("age"),null=True)
gender = models.CharField(("gender"), max_length=50,choices=GENDER_CHOICES,null=True)
nationality = models.CharField(("nationality"), max_length=50,null=True)
def __str__(self):
return "@{}".format(self.username)
I just mentioned user model in this question but still if more code is require then tell me I'll update my question with that information . Thank you