2

I deleted my database and tried to create a new one. I did:

  1. python manage.py makemigrations
  2. python manage.py migrate

Then I ran python manage.py runserver and it returned

You have 2 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): social_django.
Run 'python manage.py migrate' to apply them.

Then I ran python manage.py migrate and it returned

Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions, social_django
Running migrations:
  No migrations to apply.

I am using django 3.0.7 and social-auth-app-django 4.0.0

BM835
  • 58
  • 2
  • 8

3 Answers3

1

The solution was to disable the environment.

I don't know why.

BM835
  • 58
  • 2
  • 8
0

You can check to see which migrations have been done by viewing your database with whichever program you use to do that. And checking the django_migrations table.

The migrations that need to be applied will still be in the migrations folders for the apps that haven't been updated. To get them migrated, assuming they're still in your installed_apps in your settings.py, simply delete the migrations (probably __init__.py) from the migrations folders and re-run :

> python manage.py makemigrations
> python manage.py migrate
Lawrence DeSouza
  • 984
  • 5
  • 16
  • 34
  • Now django doesn’t print `You have 2 unapplied migration(s)', but the model still not working. – BM835 Jun 24 '20 at 04:45
  • Ok, then you'll have to go into the table django_migrations, and delete the rows for the missing apps. i.e. delete the 0001_initial and any subsequent migrations if they exist. Django will then be able to recognize that they are missing. – Lawrence DeSouza Jun 24 '20 at 05:05
  • now `python manage.py migrate` fails with `model_state = state.models[app_label, self.name_lower]` `KeyError: ('social_django', 'association')` – BM835 Jun 25 '20 at 03:31
  • That sounds like a refactoring issue. You might have to restore the 0001 initial migration file for that app, and change whatever name was changed, back to the original and run makemigrations again. – Lawrence DeSouza Jun 25 '20 at 04:32
  • I returned the modified file and returned to the first error (`You have 2 unapplied migration(s).`) – BM835 Jun 25 '20 at 04:58
0

run the following command on your command prompt:

1.python manage.py migrate
2.python manage.py runserver

enter image description here

Trinh Hieu
  • 379
  • 3
  • 6