0

I am developing a django app in virtual environment. Django version 1.9.7.

I splitted the models.py into multiple files and kept them in a folder with __init__.py file.

|-- Models
|   |-- __init__.py
|   |-- PersonModel.py
|   `-- VehicleModel.py

Content of init.py file is -

from .VehicleModel import *
from .PersonModel import *

Inside VehicleModel.py file, I created a model.

from django.db import models

class Vehicle(models.Model):
        regNo = models.charField(max_length=16, null = False, blank = False, primary_key = True )
        chassisNo = models.charField(max_length=64)
        engineNo = models.charField(max_length=64)
        manufacturer = models.charField(max_length=128)
        product = models.charField(max_length=128)

Now when I am running python manage.py makemigrations MyAppName it says No changes detected in app 'MyAppName'

I did initial migrations and default tables are created in DB.

Also I don't have anything in migrations folder except init file.

Anurag Rana
  • 1,429
  • 2
  • 24
  • 48
  • you have forgotten to delete the old models.pyc – e4c5 Aug 04 '16 at 10:39
  • There is not a single .pyc file. I deleted them bcz I was getting some errors. find . -name '*.pyc' -delete – Anurag Rana Aug 04 '16 at 10:42
  • @User42 Ya, I just googled and it says the `python manage.py sql APP_Name` has been discontinued. Let me look for an alternate. And hence I must also take down my answer. – Ankush Raghuvanshi Aug 04 '16 at 10:58
  • I found `sqlmigrate`, but I don't think it really solves your purpose. See this -> http://stackoverflow.com/questions/35455706/equivalent-of-sqlall-in-django-1-9 The last comment says that there is no equivalent for `manage.py sql` now – Ankush Raghuvanshi Aug 04 '16 at 11:07
  • Thanks. sqlmigrate expects migration name and I don't have anything in migrations folder. updated the same in question. – Anurag Rana Aug 04 '16 at 11:22
  • Yea. Plus according the docs also, it doesn't really serves the purpose you are looking for. – Ankush Raghuvanshi Aug 04 '16 at 11:52

1 Answers1

0

Just import all models into 'models.py' as the django look up for models in models.py for migrating a schema.

Pang
  • 9,564
  • 146
  • 81
  • 122
Rajesh
  • 131
  • 4