Django 1.7c1 app without models data migrations

2,856 views
Skip to first unread message

aRkadeFR

unread,
Jul 15, 2014, 10:20:57 AM7/15/14
to django...@googlegroups.com
Hello everyone,

First post on this mailing list. Big thanks to the community and the core dev
of Django!

I'm using Django 1.7c1 with python 3.2 or 3.4.

I'm splitting lots of my website as Django apps. So my main app is handling
(only) the urls routing, the settings, some tests and that's it.

I want to do some data migrations. For example add some
django.contrib.sites.models.Site objects to the database when I migrate my
app. Or some flags (django-waffle) etc. All the data relates to this app.

I don't want to put this data migration into the django.contrib.sites folder
cause it's already packaged as root etc. So it's not runnable from my
development user (to create or read the file into the folder). And it's the
same problem for all these apps I want to add data into.

If I run "python3 manage.py makemigrations --empty <app>", it create the
0001_initial.py migrations. I create the function to add the data inside the
database, and try to run the migrations with "python3 manage.py migrate
<app>", but get the error:

"CommandError: App <app> does not have migrations (you cannot selectively
sync unmigrated apps)"

So I'm searching how can I make this <app> migrated? Create an empty initial
migrations? so the django migrations take this app into account.

Thank you for all your help

aRkadeFR

j1z0

unread,
Jul 16, 2014, 10:07:06 AM7/16/14
to django...@googlegroups.com, con...@arkade.info
Are you sure you have your django app in your settings.INSTALLED_APPS and your django app has a migrations folder underneath it with an __init__.py file?

I'm pretty sure that should be all you need to have in place so you can run a migration.

Cheers,
Jeremy

aRkadeFR

unread,
Jul 17, 2014, 7:59:03 AM7/17/14
to django...@googlegroups.com

After some tests, the problem came from the lack of the file models.py
The __init__ is there and is ok.

If I run without models.py file:
python3 manage.py migrations <app> --empty
python3 manage.py migrate

-> that doesn't take into account my <app>

But if I run the same commands with models.py (even empty), it takes into
account my app and migrate it.

Seems to be something weird to me, cause the 0001_initial.py migration is
exactly the same generated file either case.

Anyway, problem solved, but weird behavior from my point of view? If anyone
can tell me why…

Thanks for the help :)
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2c369324-da9a-4e3e-a6f1-16cec96cc3cd%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages