Opened 16 years ago

Closed 13 years ago

#6550 closed (fixed)

tutorial part 4 - Use generic views not equivalent to "the hard way" results

Reported by: alexandre.dupas@… 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


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)

tutorial4_6550.diff (2.6 KB ) - added by Vegpuff 16 years ago.
Making changes in tutorial3 so as be similar in tutorial4.

Download all attachments as: .zip

Change History (5)

by Vegpuff, 16 years ago

Attachment: tutorial4_6550.diff added

Making changes in tutorial3 so as be similar in tutorial4.

comment:1 by Vegpuff, 16 years ago

Cc: vegpuff@… added
Owner: changed from nobody to Vegpuff
Triage Stage: UnreviewedAccepted

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.


comment:2 by Vegpuff, 16 years ago

Has patch: set

comment:3 by Vegpuff, 16 years ago

Cc: veg.puff@… added; vegpuff@… removed

comment:4 by Tim Graham, 13 years ago

Resolution: fixed
Status: newclosed

(In [15068]) Fixed #6550 - Changed generic view portion of the tutorial so it's equivalent to "the hard way" results. Thanks Alexandre Dupas for the suggestion.

Note: See TracTickets for help on using tickets.
Back to Top