pythondjangozinnia

Fresh Django Server, added Zinnia to project according to official docs, does not work. Many details inside


The server is a virtual Ubuntu machine that I setup today, according to these directions/notes (I made notes where I deviated from the tutorial):

https://www.evernote.com/shard/s50/sh/5c4f5ed1-bdb0-40c1-b9de-39fae702d709/d906be4f255c36241a3b76bf6fc7e7b7

That got the Django "It worked!" page at the server's address on the local network. I then followed the instructions at the official site (I can't post too many links, my reputation is too low), and when I tried to do a ./manage.py syncdb, I get the following error:

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

The Zinnia urls (/weblog/ and /comments/) produce 404 errors that indicate that the Zinnia urls, which are definitely in the project's urls.py, are not making it out of urls.py. I suspect the syncdb error has something to do with this:

Using the URLconf defined in homepage.urls, Django tried these URL patterns, in this order:
    ^admin/
The current URL, weblog/, didn't match any of these.

To be explicit, starting from a working Django server, I did the following, according to directions (I'm restating the steps I have taken so that it's totally clear):

I'm also a bit confused about the fact that there is no editable python code in the project directory - does Zinnia run completely like a black box? Oh, I also made sure all the requirements were installed, and I pasted the requirements.txt, but the site thought it was code and wouldn't let me post it. Anyways, everything listed on the Zinnia install page is in there.


Solution

  • Make sure you have all of the required installed apps. Note there are a few django.contrib apps that are required, including django.contrib.sites, which your error message indicates you missed.

    Relevant portion of docs here.

    EDIT:

    INSTALLED_APPS requires at least the following:

     INSTALLED_APPS = (
      'django.contrib.auth',
      'django.contrib.admin',
      'django.contrib.sites', # Note this one is not included by default
      'django.contrib.comments', # Note this one is not included by default
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'django.contrib.contenttypes',
      'tagging',
      'mptt',
      'zinnia',
    )
    

    Also, you'll likely need to add a SITE_ID setting.

    SITE_ID = 1
    

    Sites framework setup here.

    EDIT 2:

    Since Django 1.6 django.contrib.comments is a separated project: django_comments.

    You must install it as in this quick install guide and add 'django_comments' in INSTALLED_APPS (not 'django.contrib.comments').