#5216: Lazy Translation label_tag in new forms
-------------------------+--------------------------------------------------
Reporter: anonymous | Owner: adrian
Status: new | Component: django.newforms
Version: SVN | Resolution:
Keywords: | Stage: Unreviewed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-------------------------+--------------------------------------------------
Comment (by anonymous):
I'm using mod_python Apache 2.2.4. I haven't used the dev server at all so
I don't know if it works with that. Here is an stripped down example:
{{{
from django import newforms as forms
from django.utils.translation import ugettext_lazy as _
class ContactForm(forms.Form):
name = forms.CharField(label=_("Name:"))
email = forms.EmailField(label=_("E-mail:"))
}}}
Then in a view:
{{{
form = ContactForm(auto_id=True)
return render_to_response(template_name, context_instance =
RequestContext(request, 'form':form))
}}}
The template is:
{{{
{% load i18n %}
{% if form %}
<form action="{{link}}" id="mainform" method="post">
{% if sent %}
<p>{{ sent }}</p>
{% endif %}
{% for field in form %}
<p>
{% if field.label %}{{field.label_tag}}<br/>{% endif %}
{{ field }}</p>
{% if field.errors %}{{ field.errors }}{% endif %}
{% endfor %}
<p class="button"><input type="submit" value="Send" /></p>
</form>
{% endif %}
}}}
If you need more info or if something still isn't clear lmk.
--
Ticket URL: <http://code.djangoproject.com/ticket/5216#comment:3>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---