[Fixed]-'ColorField' object has no attribute 'model' django

1👍

You’re using the model ColorField in your form, but those are two completely different contexts. It also looks like you’re trying to use a regular form as a ModelForm.

Introduction to ModelForms.

Change your form to look like this:

class EventForm(forms.ModelForm):
    class Meta:
        model = Event
        fields = ['name', 'beggining_time', 'ending_time', 'color']

This will automatically use the ColorWidget form field widget when rendering.

Leave a comment