Mar-04-2024, 06:32 PM
Obviously, there is some related code that isn't posted. Article would raise a NameError if it was not defined. My guess is Article is a class, something like this from the django documentation:
class Article(models.Model): pub_date = models.DateField() headline = models.CharField(max_length=200) content = models.TextField() reporter = models.ForeignKey(Reporter, on_delete=models.CASCADE)I wonder if the problem is here:
articles = forms.ModelChoiceField( queryset=Article.objects.all(), widget=forms.RadioSelect, required=False )I would set queryset=None since you update the quereset in the __init__ method.