On Tue, Oct 7, 2008 at 7:31 PM, Leon Yeh | New Avenue.net
<[EMAIL PROTECTED]> wrote:
> Hi Ronny, terima kasih... :-)
Sama-sama :-)
> I am trying to generate different output for css styling purpose.
>
> For example for select widget I need to generate
> <p> <label> <input>
>
> and for other controls, I need to generate
> <p class="something"> <input> <label>
>
> I don't know how field.as_widget would help.
Right. I can see how this is useful for creating a generic form template.
In that case, I'd probably write a custom tag to do the job, probably
something along the line of:
{% if_widget_select field %}
This is something similar that I had done previously:
from djblets.util.decorators import blocktag
register = Library()
@register.tag
@blocktag
def if_is_select_field(context, nodelist, field):
if isinstance(field, forms.MultipleChoiceField):
return nodelist.render(context)
else:
return ''
You can find djblets tag helpers here: http://www.chipx86.com/blog/?p=245
Cheers,
Ronny
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---