This is django-gollum, a better way to mess with styling Django forms. gollum provides a better way to specify just the HTML Attributes and CSS classes you need on a Form subclass.
All dependencies are handled for you if you install using pip.
Adding HTML or CSS to a Django Form with gollum is easy:
- Subclass gollum.forms.Form or gollum.forms.ModelForm.
- Add a Attrs or CSS inner class specifying fields with extra HTML attributes or CSS, respectively.
Here’s an example:
from gollum import forms
class MyForm(forms.Form):
foo = models.CharField(max_length=50)
bar = models.IntegerField()
class Attrs:
bar = { 'placeholder': 25 }
class CSS:
foo = 'green'
bar = ['purple', 'translucent']
When this form is rendered in the template, the “foo” <input> tag will have the “green” CSS class applied, and the “bar” <input> will have both “purple” and “translucent” applied. Additionally, the “bar” <input> would have placeholder="25" set as an HTML attribute.
If you think you’ve found a bug in django-pgfields itself, please post an issue on the Issue Tracker.
For usage help, you’re free to e-mail the author, who will provide help (on a best effort basis) if possible.
New BSD