1👍
✅
When you run migrations, the model classes aren’t directly available. That’s because your database and the class might differ (until the migration is ran…).
You can replace your method like this:
def number(self):
return self.objects.count() + 1
Note:
If if folio == None
is not necessary. That cannot happen, count()
will return an integer. Also in Python, you can write this: if folio is None
.
Source:stackexchange.com