Friday, July 1, 2011

ListView.get_context_data Exception

I implemented a silly thing that ended up getting reworked because I couldn't make Django work in the way my (silly) design wanted it to.  Here was the situation:

1.  I wrote a class based (Django 1.3) view named HomepageView that inherited from ListView
2.  I defined a post method for HomepageView which would save a form that was posted to it.
3.  Inside the post, if the form validates, I redirect the user, which works well
4.  Inside the post, if the form is not valid, I try to put the bound form (with validation errors) into the context and then render the page like normal

I receive this traceback.  Which is telling me that when ListView.get_context_data is called it can't find the object named 'object_list'.

I don't know why this is occurring.  The path of execution calls ListView.get_context_data twice, yet when it is called from within my post function it fails strangely.  I know what I'm doing is kind-of strange, but it should work right?

Enlighten me...

Thanks,
Brian

--
Brian Bouterse
ITng Services

--
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.

No comments:

Post a Comment