Opened 9 years ago

Closed 6 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: master
Severity: Keywords:
Cc: veg.puff@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


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 9 years ago.
Making changes in tutorial3 so as be similar in tutorial4.

Download all attachments as: .zip

Change History (5)

Changed 9 years ago by Vegpuff

Attachment: tutorial4_6550.diff added

Making changes in tutorial3 so as be similar in tutorial4.

comment:1 Changed 9 years ago by Vegpuff

Cc: vegpuff@… added
Needs documentation: unset
Needs tests: unset
Owner: changed from nobody to Vegpuff
Patch needs improvement: unset
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 Changed 9 years ago by Vegpuff

Has patch: set

comment:3 Changed 9 years ago by Vegpuff

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

comment:4 Changed 6 years ago by Tim Graham

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