Django 1.7 - App 'your_app_name' does not have migrations
Asked Answered
B

5

21

I am trying to upgrade from Django 1.6.7 to Django 1.7.1, so I have been trying to migrate my app.

I have followed the django docs here.

I deleted the south from my installed apps.

In the migration directory, I delete the numbered migration files and the .pyc files but I kept the directory & __ init__.py file.

I then run :

python manage.py makemigrations your_app_name

I receive the following confirmation message:

Migrations for 'your_app_name':
  0001_initial.py:
    - Create model UserProfile

Next I run:

python manage.py migrate your_app_name

I received the following error:

CommandError: App 'your_app_name' does not have migrations (you cannot selectively sync unmigrated apps)

As per the docs, I also ran:

python manage.py migrate --fake your_app_name

I received the same error message:

CommandError: App 'your_app_name' does not have migrations (you cannot selectively sync unmigrated apps)

Can anyone shed some light on why this will not work for me?

Beaner answered 3/11, 2014 at 5:50 Comment(2)
does makemigrations created a new file in your migrations folder?Mast
yes. the new file is called 0001_initialBeaner
S
31

I noticed that only those apps that actually contain a migrations folder that contain a file __init__.py are recognized by migrations. IE having only models.py in your app is not enough.

Sundried answered 8/2, 2018 at 16:9 Comment(0)
P
16

If you have a single app, running migrate without specifying the app or migration may work.

If so, the first thing to check is that your app name matched that specified in your settings.py under INSTALLED_APPS.

As pointed out in the comments, app names can be in the form [parent_app].[app_name]. In this case, migrate needs [app_name] only.

Perspire answered 22/12, 2014 at 15:24 Comment(2)
This second part may be a bit confusing to people that land here, because the installed app name may be '[parent_app].[app_name]' whereas the migrate.py command will just want [app_name]. Confusing that can give the same error as the original poster.Wonted
THANK YOU @TheCardCheat! I was using parent_app.app_name and getting nowhere.Regenerate
C
9

Your app must contain a models.py file (even emtpy).

Source: https://groups.google.com/forum/#!msg/django-users/bsTZEmxgDJM/wH0p3xinBWIJ

Cavan answered 4/12, 2014 at 14:6 Comment(0)
T
3

Just to mention another possible reason:

In my Django app i added the correct migrations and installed the app with pip and got the same error.

What i was missing is a correct MANIFEST.in file Also the parameter include_package_data in setup() from the setup.py file was not set to True.

Tnt answered 1/6, 2017 at 9:23 Comment(0)
I
0

Please ensure the following:

  1. Confirm that 'app_name.apps.AppNameConfig' is added to the list of installed apps.
  2. Double-check the project's database configuration in the settings.py file.
  3. Make sure that each application includes a directory named migrations, and within that directory, there is a file named __init__.py.
Ignescent answered 16/6, 2023 at 16:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.