charettes / django-colorful

Extension to the Django web framework that provides database and form color fields
https://pypi.python.org/pypi/django-colorful
MIT License
169 stars 58 forks source link

RGBColorField requires db model #16

Closed thomwiggers closed 10 years ago

thomwiggers commented 10 years ago

When trying to use RGBColorField in a regular forms.Form, the field chokes on arguments such as 'label'.

charettes commented 10 years ago

It's quite hard to identify your issue from your subject and your description.

Can you provide a traceback of the raised exception with the form definition that causes an issue?

thomwiggers commented 10 years ago
from colorful.fields import RGBColorField

class MyForm(forms.Form):
    foo_element = RGBColorField(required=True, label="My Field Label")

TypeError: __init__() got an unexpected keyword argument 'label'

charettes commented 10 years ago

colorful.fields.RGBColorField is a database field and not a form one.

What you want to do it the is the following:

from django import forms
from colorful.fields import RGB_REGEX
from colorful.widgets import ColorFieldWidget

class MyForm(forms.Form):
    foo_element = forms.RegexField(
        regex=RGB_REGEX, widget=ColorFieldWidget,
        required=True, label="My Field Label"
    )
thomwiggers commented 10 years ago

Ahh. Wouldn't it make sense to just provide a form field as well?

charettes commented 10 years ago

I'm not against the idea if you want to provide a PR.

thomwiggers commented 10 years ago

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512

Let me put that somewhere on the todo list...

On 5 October 2014 21:09:19 CEST, Simon Charette notifications@github.com wrote:

I'm not against the idea if you want to provide a PR.


Reply to this email directly or view it on GitHub: https://github.com/charettes/django-colorful/issues/16#issuecomment-57948349


Sent from my Android device with K-9 Mail. Please excuse my brevity. -----BEGIN PGP SIGNATURE----- Version: APG v1.1.1

iIIEAREKACoFAlQxmAQjHFRob20gV2lnZ2VycyA8dGhvbUB0aG9td2lnZ2Vycy5u bD4ACgkQQXX1nPPrRfzeAQEAlFD91gB19cwdc8aJAvgtJynCNrWhrEU8p/6f8C7Q PdoA/jC48gNJmR5PJ2+4LPYlpJdqVBDjV7kMGoJcRfuxPT7W =06O3 -----END PGP SIGNATURE-----