Python Django Forms Model Forms Create a Model Form

Eric Shelby
Eric Shelby
22,230 Points

Create a Model Form Challenge

According to the instructions: 'We need to make a model form for our Digital product model. We have a couple of fields on Product, its parent, though, that we don't want in our form.

Make a model form for Digital and name the form class DigitalProductForm. Only include the name, description, and url fields.'

However, I don't how to turn a model form for Digital. The lesson didn't cover that. I tried a few ways, but none of them worked. A hint would be appreciaed.

products/forms.py
from django import forms

from . import models


class DigitalProductForm(forms.ModelForm)
    class Meta:
        model = models.DigitalProduct
        fields = ['name', 'description', 'url',]

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 51,392 Points

You are very close! There is a colon missing from the end of the class definition. While the form is DigitalProductsForm, the model it's based on is Digital not DigitalProducts. Fix these and it should pass.

Post back if you need more help. Good luck!!

Eric Shelby
Eric Shelby
22,230 Points

Thanks, Chris. Your advice did the trick.