Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
Django 1.10 makemigrations errors

I am having major problems getting a Django app installed on an Ubuntu machine running Django 1.10.6.

I am used to using an older version of Django and now I cannot get my webapp to install. Here is the situation:

I have a Django project called myproject. The file structure is:

(BASEDIR)/manage.py
(BASEDIR)/mycommon/    # I will discuss mycommon below
(BASEDIR)/myproject/
(BASEDIR)/myproject/settings.py
(BASEDIR)/myproject/urls.py
(BASEDIR)/myproject/views.py
(BASEDIR)/myproject/wsgi.py
(BASEDIR)/myproject/models/
(BASEDIR)/myproject/models/__init__.py
(BASEDIR)/myproject/models/models.py

It turns out that for this project I need to put my models in a common package because there is another python application (using Twisted that bootstraps Django) that needs to access these models. I will call this package "mycommon". So my "real" models are here:

(BASEDIR)/mycommon/
(BASEDIR)/mycommon/utils.py
(BASEDIR)/mycommon/models/
(BASEDIR)/mycommon/models/__init__.py
(BASEDIR)/mycommon/models/models.py

So the Django settings file is in (BASEDIR)/myproject/settings.py and the INSTALLED_APPS parameter is set to this:

INSTALLED_APPS = (
'myproject.models',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
)

Finally, note that myproject/models/models.py is very simple, since it just uses the mycommon models:

from django.db import models
from mycommon.models.models import *

So far so good, this is a structure that works fine on older Django versions. Anyway, I start with an empty MYSQL database (created but empty) and now I go back to (BASEDIR) and run this:

python manage.py makemigrations mycommon.models

Unfortunately I get an error like this:

RuntimeError: Model class mycommon.models.models.SomeModel doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

So what am I doing wrong?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

In INSTALLED_APPS you should have only 'myproject', without '.models'.

But since you are using Django 1.10, it will be cleaner if you create your mycommon app via manage.py startapp mycommon. This will create, well, some files, but you should move your models to mycommon/models.py. Note the mycommon/apps.py. You don't have to touch this file, only include it in the INSTALLED_APPS list: 'mycommon.apps.MycommonConfig'. This way the migrations framework will discover your models automatically.

Finally, remove myproject/models, since myproject holds the project configuration.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!