21👍
Based on the information you provided you should check this part of Django’s documentation:
Adding views to admin sites (note: the link is valid for version 1.5 since version 1.3 is not supported anymore – the solution is still valid).
Then you could check this blog post and this question for some further inspiration and details.
Based on your example I really don’t get why you just don’t use a regular ModelAdmin
with some filtering options:
class QuestionAdmin(admin.ModelAdmin):
list_filter = ('topic',)
6👍
The pattern gets a view, not the result of calling the view, i.e.:
list_urls = patterns('', r'^list/$', self.list_view())
should be
list_urls = patterns('', r'^list/$', self.list_view)
Also, “list_view” (at this stage) is a view like any other. So it will need to return an HttpResponse object.
def list_view(self, request):
return question_list(request)
You’re not showing the code for question_list() but I have the suspicion it is not returning an HttpResponse.
P.S.: If you provided the traceback of the “‘function’ object is not iterable” exception (you’re getting this when visiting “list/” ?) there’d be less guesswork.
- [Django]-Django tests – patch object in all tests
- [Django]-Django: "projects" vs "apps"
- [Django]-Django setUpTestData() vs. setUp()
3👍
Here’s an example of everything needed to add (as of Django 1.6) for a custom page that will be linked to from a button next to the “History” button in the top right of an object’s detail page:
- [Django]-Is it OK to use multiple inheritance with Django abstract models?
- [Django]-Django admin – make all fields readonly
- [Django]-Django: order by position ignoring NULL
- [Django]-Load a Django template tag library for all views by default
- [Django]-In Django is there a way to display choices as checkboxes?
- [Django]-How to validate an Email address in Django?