I have a page called view_requests.html. One one tab on the page, I'd like to have basically a list of objects reddit style that people can upvote. I accomplished this using django-voting.
However, on a second tab, I would like the ability to add a request. This requires that I have a form that people can submit.
The problem I'm facing is that to implement the Reddit style voting, I had to use the following configuration in my URLs.py (ie. not create my own view for it in views.py). But to create a form, I need to access some code I wrote in views.py. Is it possible to have both on the same page in separate tabs, and how would I go about doing this?
url(r'^view_requests/?$', object_list, dict(queryset=LibraryRequest.objects.all(),
template_object_name='request', template_name='spicemodels/view_requests.html',
paginate_by=15, allow_empty=True), name="view_requests"),
You don't have to use that;
object_listis a built-in Django generic view. Generic being the keyword, because it's merely intended to make it easier for you if your view conforms to a standard. Since, you need more from your view thanobject_listcan provide, it's time to throw it out and write your own view. You can useobject_listas a guide for creating your own view, but there's a lot of extraneous boilerplate code in it just to make it generic. Simplistically, the following is all you need: