7👍
✅
Have you defined an Article
model somewhere? Usually it’s in models.py
in the same folder as your forms.py
and views.py
, e.g.:
from django.db import models
class Article(models.Model):
title = models.CharField(max_length=100)
text = models.TextField()
Of course, you’ll have to import the Article
model in your forms.py
:
from models import Article
2👍
You never imported any classes named Article or Book. They have to be defined in the namespace before they’re used.
2👍
Usually you’d define Article and Book in your models.py file, so from models import Article, Book
need to go in your forms code.
Source:stackexchange.com