Skip to content
Advertisement

django makemigrations not detecting new model

I used makemigrations earlier in order to make my Django app aware of the tables in my legacy MySql database, and it worked fine. It generated models.py. Now, I want to add a new “UserDetails” model to my app:

class UserDetails(models.Model):
    user = models.CharField(max_length=255)
    telephone = models.CharField(max_length=100)

After saving the file, I ran the following command in the command prompt:

python manage.py makemigrations

But makemigrations is not seeing the new class I wrote inside the models.py, as it always outputs ‘No changes detected’

Am I doing it correctly or is there anything wrong with it? I checked my MySQL db and confirmed that no table named UserDetails already exists.

Advertisement

Answer

The models.py needs to be inside the application package, rather than in the main directory for the makemigrations to work.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement