Django 1.9 Woes

54 views
Skip to first unread message

SillyInventor

unread,
Apr 7, 2016, 8:17:23 PM4/7/16
to Django users
I am trying to transition to Django 1.9 from my 1.8 app. Simply creating the migrations for old databases is fine, but when I try to create a fresh database with migrate I get:

"Error creating new content types. Please make sure contenttypes " RuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually. 

I have tested this a fair bit, and I can get it to build fresh if I: remove my site from URLs, migrate, add it back, and migrate again... but that's super janky, and not the clean build I am looking for. It seems to be caused because in Django/core/management/base.py line 398 -> self.check() is called before the migration occurs, and the lack of a database throws an error and quits before setting up the database (catch 22). I have tested this by commenting this out, and that will also allow it to build the database.

Anyone have any recommendations for what a good way to fix this is or what the underlying problem might be in my app?

Tim Graham

unread,
Apr 8, 2016, 7:26:04 AM4/8/16
to Django users
Difficult for me to say for sure without having a sample project to debug. Do you know if you have any module level queries in your project? Those are generally to be avoided and may cause problems like this. See https://groups.google.com/d/topic/django-developers/7JwWatLfP44/discussion for some discussion.

SillyInventor

unread,
Apr 8, 2016, 12:36:47 PM4/8/16
to Django users
I don't think so... The line I am getting hung up on is:
class Project(models.Model):
......
    def approved_projects():
        return Project.objects.filter(approved=True)

It seems that no matter how many things I remove from my URLs, if there is any reference to any model on the first build, it'll fail to migrate.
Reply all
Reply to author
Forward
0 new messages