20

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?

user1261774
  • 3,525
  • 10
  • 55
  • 103

5 Answers5

30

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.

Erwin Kooi
  • 373
  • 4
  • 5
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.

James Bradbury
  • 1,708
  • 1
  • 19
  • 31
  • 4
    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. – Jmills Jan 16 '15 at 17:23
  • 2
    THANK YOU @TheCardCheat! I was using `parent_app.app_name` and getting nowhere. – annapetry Feb 07 '16 at 02:34
8

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

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

Pascal Polleunus
  • 2,411
  • 2
  • 28
  • 30
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.

-1

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.
Esmaeil MIRZAEE
  • 1,110
  • 11
  • 14