Stupid.Fat.Cat
Stupid.Fat.Cat

Reputation: 11285

makemigrations not detecting changes after moving models to a modelsdirectory

My old structure used to be like this:

models.py
    class Model1
    class Model2
    ...

I have since moved this to

modelsdir
   __init__.py
   model1.py
      class Model1
   model2.py
      class Model2
models.py
   from modelsdir.model1 import Model1
   from modelsdir.model2 import Model2

After this change, makemigraitons and makemigrations myapp no longer detect any changes done on the models. Any idea how to fix this?

EDIT:

I have since moved to this: removed models.py and renamed modelsdir to models

now it looks like so:

models
    __init__.py
        from .model1 import Model1
        from .model2 import Model2
    model1.py
    model2.py

Unfortunately this still doesn't detect any changes.

Upvotes: 0

Views: 172

Answers (1)

Nathan Jones
Nathan Jones

Reputation: 5144

I have a django project that is structured this way, and I had to add this in my modelsdir/__init__.py file:

from .model1 import *
from .model2 import *

I also didn't keep the original models.py file in my top-level app folder.

This is on Django 1.10/1.11 and Python 3.

Upvotes: 1

Related Questions