Last modified: May 06, 2021

How to Solve AttributeError: module 'django.db.models' has no attribute 'model' in Django

Today, I'll show you how to solve AttributeError: module 'django.db.models' has no attribute 'model' and AttributeError: module 'django.db.models' has no attribute 'models' in django.

AttributeError: module 'django.db.models' has no attribute 'models'

This issue appears when you write your model field with double models:

Bad:


name = models.models.CharField(max_length=50)

To solve the issue, you need to follow the code bellow

Good:


name = models.CharField(max_length=50)

AttributeError: module 'django.db.models' has no attribute 'model'

you'll get this issue if you write the parameter of your model class without uppercase.

Bad:


class TestModel(models.model):
    ...

Good:


class TestModel(models.Model):
    ...