Importing django.db.models.fieldsΒΆ
In Django, models are defined in django.db.models.fields. However, for convenience they are imported into django.db.models. Djangoβs standard convention is to use from django.db import models and refer to fields as models<some>Field. To improve readability and maintainability of your code, change your import statement and model definition.
Anti-patternΒΆ
from django.db.models import fields
class Person(models.Model):
first_name = fields.CharField(max_length=30)
last_name = fields.CharField(max_length=30)
Best practiceΒΆ
Stick to standard conventions and use from django.db import models instead.
from django.db import models
class Person(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)