Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda