I've created a Django application and I have a model like such:
class Company(models.Model):
name = models.TextField(max_length = 200)
When I run python3 manage.py makemigrations appname, everything works as expected, and a migration file for the class is created.
The problem happens if the class in the model defines a Meta class as well:
class Company(models.Model):
name = models.TextField(max_length = 200)
class Meta:
app_label = "Companies"
Now, if I run the makemigrations command, I either get a "no changes detected" message, and no migration file is generated:
> python3 manage.py makemigrations myApp
No changes detected in app 'appname'
Or, worse yet, if the model with the Meta class had no dependencies (foreign keys), a migration is created that will drop the model/table entirely.
Or, if there is a dependency (foreign key reference from another model), I get an error like so:
matcher.OtherTable.foreignkeyref: (fields.E300) Field defines a relation with model 'Company', which is either not installed, or is abstract.
All models with a Meta class defined will not generate a migration, either an initial one or any subsequent migration for some reason. Classes that have Meta added after the fact will be removed at the next migration. It becomes as if they don't exist at all.
I'm using Python 3.8.3 and Django 3.0.6 on Mac OS 10.15.5.