Issue
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.
Solution
The models.py needs to be inside the application package, rather than in the main directory for the makemigrations to work.
Answered By - logeeks
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.