i wrote a couple of filters and do this....maybe not as efficient..but
works for me...


{% filter label_asterisk_red %}
    {{ posting_form|mark_required }}
{% endfilter %}


import re
from django import template
from django.template.defaultfilters import stringfilter

register = template.Library()

label_exp = re.compile(r'(?P<precede>\<label.*\>.*)\*')

@register.filter("mark_required")
def truncate(form):
  for k,v in form.fields.items():
    if v.required:
      v.label = v.label or k
      v.label += '*'
  return form

@register.filter("label_asterisk_red")
def label_asterisk_red(value):
    return label_exp.sub('\g<precede><font class="required">*</font>',
value)




On Oct 27, 3:31 pm, andresj <[EMAIL PROTECTED]> wrote:
> On Oct 22, 11:33 am, [EMAIL PROTECTED] wrote:
>
> > So, in the template, I was hoping to be able do something like:
>
> > <b>{{field.label_tag}}:</b> {{field}}
> > {% if field.error%}
> >     <font color="red"><b>{{ field.error }}</b></font>
> > {% else %}
> >    {% if field.required%} <font color="red">*</font>{% endif %}
> > {% endif %}
> > {% if field.help_text %}}  <font
> > color="silver">{{ field.help_text }}</font>{% endif %}
>
> Almost like that, just subsitite field.required to
> field.field.required. field is a BoundField, and field.field is the
> Field (e.g. CharField, IntegerField) that is set in the Form.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to