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

why db storage '#' symbol? #30

Closed mrgaolei closed 8 years ago

mrgaolei commented 8 years ago

I found that in db django-colorful storage '#ff0000' with varchar(7). But why using archer(6) and storage 'ff0000'?

charettes commented 8 years ago

I assumed you meant varchar(6) and not archer.

This format was chosen to be based on the W3C spec instead.

If you're asking in term of optimal storage performance note that most database store varchar(n) using the same way for most value of n which only results in a database constraint. If we really wanted to save storage we should use some kind of binary or integer field in the first place.

mrgaolei commented 8 years ago

Or use char(6) to instead of varcher(7)? Because I want use ColorField to be primary_key and for many ForeignKey.

charettes commented 8 years ago

Django's CharField use varchar internally and can be used as primary keys and be referenced by ManyToField fieds. I'm not sure I understand what you mean here.