Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django CMS fails to synch db or migrate

Tags:

I'm very new to django and in turn the django-cms app.

I have followed the tutorial step by step: (from the offical website ) on a new machine and have everything exactly as the tutorial does yet I still can't get anywhere.

I get to the final step in the setup process and everything falls over, When I run:

python manage.py syncdb --all

I get the following error:

CommandError: One or more models did not validate:
cms.page: 'site' has a relation with model <class 'django.contrib.sites.models.Site'>,     which has either not been installed or is abstract.
cms.globalpagepermission: 'sites' has an m2m relation with model <class 'django.contrib.sites.models.Site'>, which has either not been installed or is abstract.

To clarify this is happening at step 1.3.2.1. Fresh install in the tutorial

1.3.2.1. Fresh install

Run:

python manage.py syncdb --all
python manage.py migrate --fake

None of these commands work, both result in the above error.

I am not sure how to solve this or even find resource as to what is causing my problem, I have spent a short amount of time on both google and stackoverflow looking for answers with no result, I haven't been able to pin point the problem which is probably making things harder for me.

Any help is much appreciated.

My code is exactly the same as the tutorials which is why I haven't posted any.

like image 623
Daniel Tate Avatar asked Nov 17 '13 03:11

Daniel Tate


People also ask

How do I fix migration issues in Django?

you can either: temporarily remove your migration, execute python manage.py migrate, add again your migration and re-execute python manage.py migrate. Use this case if the migrations refer to different models and you want different migration files for each one of them.

What is difference between migrate and Makemigrations in Django?

migrate , which is responsible for applying and unapplying migrations. makemigrations , which is responsible for creating new migrations based on the changes you have made to your models.

Is Django migration necessary?

No, you don't need to use migrations. (Also, it may be relevant to note that you can use raw SQL, but Django will still set up some things for you so you can use its ORM, even with legacy databases. But migrations are not one of these things it does for you.)

Where are Django migrations stored in database?

Migrations are stored within the <app_name>/migrations directory.


1 Answers

I'm guessing that you are using the new Django 1.6. There the sites application is no longer included by default in your project. And as it seems the django-cms depends on it.

You can add it easily to the list of enabled applications in your settings.py file, in the INSTALLED_APPS list:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',    # <----- here!
    ...
like image 125
rodrigo Avatar answered Oct 04 '22 03:10

rodrigo