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.
I've met this problem during development and this combination helps me:
python manage.py makemigrations mymodule
This command create migrations for the specific module. It should be in INSTALLED_APPS
, but you'll get warning if it's not in there.
python manage.py migrate
Also, mention answer by xiaohen, I've create packages with PyCharm, so I've got init.py file by default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With