Opened 17 years ago
Closed 14 years ago
#6550 closed (fixed)
tutorial part 4 - Use generic views not equivalent to "the hard way" results
Reported by: | Owned by: | Vegpuff | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | ||
Cc: | veg.puff@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In the fourth part of the tutorial, when using generic views to replace the previously presented "hard way" code, the obtain result is not equivalent.
Indeed, the hard way shows only 5 polls on the "index" page. The generic way shows all of the possible results.
It would be useful to present the exact same behavior using the both approaches.
A possible answer to that request would be to use an extra select_dict initialized with
select_dict = { 'queryset': Poll.objects.all().order_by('-pub_date')[:5], }
and modify the first urlpatterns with
(r'^$', 'django.views.generic.list_detail.object_list', select_dict),
As I am a beginner with django (and Python too) it might exist a better solution but at least this one works.
Attachments (1)
Change History (5)
by , 17 years ago
Attachment: | tutorial4_6550.diff added |
---|
comment:1 by , 17 years ago
Cc: | added |
---|---|
Owner: | changed from | to
Triage Stage: | Unreviewed → Accepted |
Hi,
I have added a patch, to remove the top 5 listings from the tutorial 3 so as to have consistency with tutorial 4, which lists all the poll entries.
Thanks
Vegpuff
comment:2 by , 17 years ago
Has patch: | set |
---|
comment:3 by , 17 years ago
Cc: | added; removed |
---|
comment:4 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Making changes in tutorial3 so as be similar in tutorial4.