On Wednesday, July 4, 2012 8:12:50 PM UTC+2, nef wrote:
>
> Hello,
>
Bonjour
> I want to cry a function allowing me to complete a template *. Xml. May I
> have a problem with the passage of the object render_to_response. In short
> here is my code. In fact, I do not know how to return an object that can
> permattre me to complete my template automatically.
> I am using django 1.1 and Python 2.6
> Function writes to the file views.py
>
> def main_formation(request, formation_id):
> formations = Formation.objects.get(id=formation_id)
>
You name your variable "formations" (plural) but your query returns a
single Formation instance.
> variables = RequestContext(request, {
> 'formations': formations
> })
> return render_to_response('saisie/formation.xml', variables)
>
> This is mu xml template
>
> (snip headers)
>
> {% if formations %}
> <cdm:contacts>
> <cdm:contactData>
> <cdm:adr>
>
<cdm:locality>{{ formation.ville }}</cdm:locality>
>
You named the variable "formations" (plural) but you're trying to access an
indexistant "formation" (singular) object. This will eval to the
settings.TEMPLATE_STRING_IF_INVALID value, which by default is an empty
string. For developpment, it might help to set TEMPLATE_STRING_IF_INVALID
to a more obvious value (I personnaly use "XXX:INVALID").
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/QOUNvX6jcz8J.
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.