Write a wrapper function and make it even shorter (ok, go ahead and call it
syntax sugar):
def css(field, **kwargs):
field.attrs.update(**kwargs)
use as:
css(self.fields['release_date'], div_css="test")
DISCLAIMER: not tested on a real Field, but I tested it on a simple class in
a python shell and it seemed to work
I'll leave it as homework for you to make this a class method and make the
syntax even shorter. Maybe even propose a patch!
Cheers,
André Terra / airstrike
On Wed, Jul 13, 2011 at 2:47 PM, Shawn Milochik <[email protected]> wrote:
>
>
> Following this as a sample (from the docs you linked to):
> widget=forms.TextInput(attrs={**'class':'special'}))
>
> You'd do this:
> widget=forms.TextInput(attrs={**'div_css':'test'}))
>
> Or, to not clobber other things set in the form, you could do it in the
> __init__:
>
> #working example I just did in one of my projects to prove it works
> self.fields['release_date'].**widget.attrs["div_css"] = 'test'
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to django-users+unsubscribe@**
> googlegroups.com <django-users%[email protected]>.
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
> .
>
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.