15
votes

So, I finally gave in and grabbed South. The problem is, every time I try to follow the tutorial and run

"python manage.py schemamigration myapp --initial"

I get an error

"There is no enabled application matching 'myapp'"

--Things I have tried--

I have tripple checked my settings file, running Import South from the django shell returns no errors, and I have added manage.py containing folder to PYTHONPATH, as well as wsgi.py and settings.py.

I have run python manage.py and python C:\path\to\manage.py variants, even went into my python directory and verified that south was in the site-packages folder. syncdb runs fine, ending with "not synced (use migrations)". python manage.py migrate runs without returning errors but otherwise seems to have no effect. I have tried running the said command both before and after running syncdb, which has no effect on the outcome.

--Other potentially pertinent info--

Django 1.5.1, Python 2.7, no other external apps used, Windows 7 64 bit, python is added to the windows path, South installed via python setup.py install command. Installation completed successfully. I do not use a virtualenv, and would really prefer to avoid this as it would mean alot of refactoring of this current project's setup and wasted time. I plan to move to a virtualenv setup in the future, but not now.

What's going on? How do I fix this? Net searches revealed no good info at all, I am completely at a loss...

3
is 'myapp' in INSTALLED_APPS? does myapp/models.py exist?second
it does not exist, and really shouldnt exist. 'myapp' is the project's name, is that incorrect? does south apply only to a specific app within the project then? I have at least 6 custom apps with their own model.py files. Is there a command I should run for it to apply to the whole project instead?Dreadicon
@second, I think I know what I was doing wrong now. I was trying to use a command meant for a django APP on a django PROJECT. If I'm not mistaken, python manage.py migrate is the command which does the same thing but for the entire project. Do I still need to run shemamigration for each app first to initialize them though? If you add a formal answer, I can tag it as best answer. Thankyou for your time and help!Dreadicon
Just for the record, be careful when using tabs for autocompletion. I was getting this error because my autocomplete put 'myapp/' instead of 'myapp'.blaze
I had model.py instead of models.pyAfromanJ

3 Answers

7
votes

This error can be misleading: it is thrown not when South tries to import the app, but when it tries to get the app's models module.

  • perhaps it cannot import the application (because you didn't add its name to INSTALLED_APPS)
  • perhaps it cannot import the models module, because the file models.py does not exist, or because the directory models/ does not contain an __init__.py.

South doesn't import the models module itself. Instead, it leaves that job to django.db.models.get_app('app_of_interest'), which according to its docstring "Returns the module containing the models for the given app_label." The error message raised by get_app is, in fact, different depending on whether it failed to import the app or the model, but both exceptions are ImproperlyConfigured, and the schemamigrations script doesn't look any deeper than that.

Because South says it is accepting security updates only (it entered end-of-life with Django 1.7's migration feature), I'm not submitting a fix to its codebase, but instead documenting the problem here.

3
votes

migrations exist on a per-app basis. each app may or may not have its own migrations, but you need to create them for each app where you want to use them. (often all apps)

./manage.py migrate is a shortcut that runs migrations for all apps

3
votes

Check once whether you have included the app name in INSTALLED_APPS in settings.py