Coder Social home page Coder Social logo

Comments (4)

fabiocaccamo avatar fabiocaccamo commented on June 19, 2024

@jan-szejko-steelseries thank you for reporting this, could you show your field implementation (in your model)?

from django-colorfield.

jan-szejko-steelseries avatar jan-szejko-steelseries commented on June 19, 2024

@jan-szejko-steelseries thank you for reporting this, could you show your field implementation (in your model)?

    color = ColorPickerField(
        default='',
        blank=True,
        null=True,
        help_text=_('Choose a color. (optional)')
    )

It uses a slightly customized field:

from colorfield.widgets import ColorWidget
from colorfield.fields import ColorField
from django.template import loader
from django.utils.safestring import mark_safe


class ColorPickerWidget(ColorWidget):
    def render(self, name, value, attrs=None):
        context = self.get_context(name, value)
        template = loader.get_template(self.template_name).render(context)
        return mark_safe(template)


class ColorPickerField(ColorField):
    def formfield(self, **kwargs):
        kwargs['widget'] = ColorPickerWidget()
        return super(ColorField, self).formfield(**kwargs)

from django-colorfield.

jan-szejko-steelseries avatar jan-szejko-steelseries commented on June 19, 2024

@fabiocaccamo You can experiment on https://jscolor.com/examples/ to see that an input with data-jscolor="{required:false,palette:}" does not allow an empty value.

from django-colorfield.

fabiocaccamo avatar fabiocaccamo commented on June 19, 2024

@jan-szejko-steelseries you can upgrade to 0.7.2 version. Thank you for the PR.

from django-colorfield.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.