Question

I have just deployed a django application for the first time using MySQL as the database. In development, I am using sqlite3 and south for migrations.

I suppose I am to use python manage.py syncdb then python manage.py migrate to initialize the database. However, when I run python manage.py syncdb for the first time in production, I get the following error:

DatabaseError: relation "utils_message" does not exist LINE 1: ...sage"."message_type", "utils_message"."text" FROM "utils_mes...

What could I be missing? Could it be a cyclic dependency of some sort?

My INSTALLED_APPs setting looks like this:

INSTALLED_APPS = (
     'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions',
     'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles',
     'south', 'django.contrib.admin',  'mainapp', 'employerprofile', 'applicantprofile',
     'companies', 'postings', 'utils', 'searchjobs', 'comments', 'projectapp',
     'cart',  'applications', 'packages', 'feedback', 'cvbank', 'staffpostings',
     'logs',
     # Uncomment the next line to enable admin documentation:                       
     # 'django.contrib.admindocs',                                                     
)
Était-ce utile?

La solution

Solved the problem. It was caused by a dependency among the models.

I did a grep on Message and discovered that a field in a model in the postings app depended on an instance of the Message model in the utils app as its default value, ie:

from utils.models import Message
...
default_message = Message.objects.get(message_type='application-receipt-message').text
...
class Posting(models.Model):
    ....
    receipt_message = models.TextField(default=default_message)
    ...

So I changed the default_message to an empty string, did python manage.py syncdb followed by python manage.py migrate, and didn't experience any more problems.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top