Code

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#18189 closed Bug (invalid)

Missing a .all() in Tutorial 4

Reported by: thungp@… Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In the section use generic views: Less code is better
in the Change it like so:

What there currently is as of 4/22/12 is as follows:
queryset=Poll.objects.order_by('-pub_date')[:5],

I believe you meant this:
queryset=Poll.objects.all().order_by('-pub_date')[:5],

Attachments (0)

Change History (6)

comment:1 Changed 2 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

The .all() can be implied in this context; it isn't required.

comment:2 Changed 2 years ago by anonymous

Well,

until I did that, I didn't get any results back when I went to the polls URL.
Plus it doesn't really follow the syntax on the Tutorial Page 3.

-Peter

comment:3 Changed 2 years ago by anonymous

  • Resolution invalid deleted
  • Status changed from closed to reopened

Btw,
I'm running django 1.4.
Based on your comment, it appears you shouldn't have to do this .all() for it to work.
I'm curious dd you actually try this and what version of django/python is this supposed to work?

-Peter

comment:4 Changed 2 years ago by Alex

  • Resolution set to invalid
  • Status changed from reopened to closed

The all() has never, at any point in Django's history been required here.

comment:5 Changed 2 years ago by anonymous

Alex,

Roger.

If I understand you correctly, then, if I remove the .all() like in the original
tutorial, and it doesn't return anything, but then put it back
and it does return something... do you have any thoughts on what the problem
could be?

Then I would suggest for consistency sake, you should consider remove the .all()
from the examples in part 3 of the tutorial, however,
I would humbly recommend testing it 1st. (which is how I managed to solve not
getting results back).
When I come home tonight, I can do that to see if it has similar effects on the
query results like I'm currently getting.
Of course, based on the feedback I've seen from this submission, it appears like
it is a localized problem with my setup
and not the norm.

I'm using sqlite3 for db backend when going through the tutorial. I'm wondering
if that has any bearing on this.
Or could it be the python version I'm using?

Regards,

-Peter

comment:6 Changed 2 years ago by thungp@…

Update,

looks like it was probably a typo or operator error. I can't seem to be able to reproduce it. It appears to work both with and without the .all().

-Peter

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.