Wednesday, November 25, 2009

View assistance

I have two models, Project and Task. They are related via a foreign
key in the task model.

The view that displays a task is below...

def task_detail(request, project_slug, task_id):
project = get_object_or_404(Project, slug=project_slug)
return object_detail(
request,
queryset=Task.objects.all(),
object_id=task_id,
template_object_name="task",
extra_context = { 'project': project }
)

The URL would look like this...

/projects/project_slug/tasks/task_id/

This is working as expected. However, the view is checking that the
project_slug is found, and also that the task_id is found, but it's
not checking that the found task is related to the found project.

Could someone get me started on how best to write a view that would do
that? I'm presuming I'd have to part company with generic views for
this?

--

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