Opened 8 years ago

Closed 5 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:

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)

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

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by vegpuff

Making changes in tutorial3 so as be similar in tutorial4.

comment:1 Changed 7 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 changed from Unreviewed to 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 Changed 7 years ago by vegpuff

  • Has patch set

comment:3 Changed 7 years ago by vegpuff

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

comment:4 Changed 5 years ago by timo

  • Resolution set to fixed
  • Status changed from new to closed

(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