Friday, August 6, 2010

For tag fails in template

What is wrong?

My view function:
def project(request, project_id):

try:

project_id = int(project_id)

except ValueError:

raise Http404

myProject = get_object_or_404(Project, id = project_id)
events = Event.objects.filter(project = myProject)


return render_to_response('project.html',

context_instance=RequestContext(request, {'project':
myProject, 'events': events}))


And in the template I do:
<div id="sidebar">
<ul>
{% for event in events %}
<li><a href="{% url event event.pk %}">{{ event.title }}</a></li>
{% empty %}
<p>{% trans "There are no events yet." %}</p>
{% endfor %}
</ul>
</div>

If there are no events, everything is fine. If some event exists, it
shows an error:

Caught NoReverseMatch while rendering: Reverse for 'event' with
arguments '(1,)' and keyword arguments '{}' not found.

and points to the for tag.

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate