fabiocaccamo / django-colorfield

:art: color field for django models with a nice color-picker in the admin.
MIT License
630 stars 95 forks source link

Color picker widget does not work in model forms #202

Closed moonburnt closed 3 weeks ago

moonburnt commented 1 month ago

Python version 3.12

Django version 4.2.7

Package version 0.11.0

Current behavior (bug description) Color picker widget does not seem to work for model forms?

Specified it like that:

from colorfield.widgets import ColorWidget
from django import forms

class MyModelForm(forms.ModelForm):
    class Meta:
       model = MyModel
       fields = [
           "background_color",
       ]
       widgets = {
           "background_color": ColorWidget,
       }

And this is what I get in the form view: image

Expected behavior "Background Color" field should have a color picker widget instead of a text input.

Additional information I'm using django-oscar for the admin interface, on which this occurs. So maybe its not a bug in this library, but a conflict with django-oscar's templates?

Upvote & Fund

Fund with Polar

fabiocaccamo commented 1 month ago

@moonburnt I'm pretty sure it's a conflict, are there errors in the browser's console?

fabiocaccamo commented 1 month ago

@moonburnt any feedback?

moonburnt commented 1 month ago

@moonburnt I'm pretty sure it's a conflict, are there errors in the browser's console?

nope, no errors in the console

fabiocaccamo commented 1 month ago

Could you try without django-oscar please?