Troy
Troy

Reputation: 21862

Django 1.7 - create initial migration

According to the Django docs, if I want to create an initial migration for an app, I should do:

$ python manage.py makemigrations my_app

However, if I do that in my project, I get:

No changes detected in app 'my_app'

even though there are no migrations for my_app yet - the my_app/migrations/ folder only has an __init__.py file.

I do NOT have managed = False in my model. The model classes in question don't even have a Meta class defined. What else can prevent Django from detecting model changes?

How does Django detect if/when there are changes?


Update:
I should add that migrations for this particular app worked fine back when I was using South migrations. It's only after upgrading to Django 1.7, and built-in migrations, that it can no longer figure out if/when there are model changes for that particular app (migrations for other apps work fine).

Upvotes: 2

Views: 721

Answers (2)

Will Keeling
Will Keeling

Reputation: 22994

A little late, but having just hit this after creating a brand new app, it suddenly dawned on me that I hadn't added the new app to the INSTALLED_APPS in the settings.py.

INSTALLED_APPS = (
    ...
    my_app,
    ...
)

Doing that and then re-running python manage.py makemigrations my_app generated the initial migration.

Upvotes: 1

n__o
n__o

Reputation: 1729

You might want to look for a "migrations" directory somewhere in your virtualenv home directory or on your path.

I ran a few times into some similar issue, when trying to migrate an app from South to Django 1.7 migrations. For some reason, Django wouldn't find the correct migrations folder, and so would create the migration into an unlikely location such as <virtualenv>/bin/myapp/migrations dir (when using django-admin.py). So everytime I'd run makemigrations Django would find this "stale" migration, and display the No changes detected in app 'my_app' message.

Sorry if I'm vague on the specifics, I'll update next time I run into this issue.

Upvotes: 0

Related Questions