Opened 11 years ago

Closed 11 years ago

#20318 closed Uncategorized (needsinfo)

Instruction errors (maybe)

Reported by: ibrahimalbarri@… 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

Okay I will take the time to provide a bit more detail on my initial ticket and attempt not to make any type O's. And, for the record I'm not complaining (I think you guys are great and that Django is the bomb!!!) just trying to help out the next person.... I'm running Django, Mysql, Mod_wsgi, on Apache in a virtenv. Im going through the Writing our first Django app and everything has worked out up until these prompts.

class PollAdmin(admin.ModelAdmin):

# ...
list_display = ('question', 'pub_date', 'was_published_recently')

for settings.py

and

class Poll(models.Model):

# ...
def was_published_recently(self):

return self.pub_date >= timezone.now() - datetime.timedelta(days=1)

was_published_recently.admin_order_field = 'pub_date'
was_published_recently.boolean = True
was_published_recently.short_description = 'Published recently?'

for modles.py

I cut and pasted this code directly from the website and got errors stating: was published recently not defined......

to fix the error I had to make 'was_published_recently' (from settings.py)

and 'Published recently?' (from models.py) exactly the same i.e was_published_recently.

Im running ubuntu 12.10 and django 1.5.....As I said in my previous ticket I dont know if this is an issue on other systems or setups but It was an issue for me. I do want to say that I am very new to programming and I didn't automatically assume or know that these two fields have to be the same thus it took two days for me to figure it out

Thanks for all your hard work and for the timely and personal response to my first ticket (like 5 min).. Lets me know I chose the right engine to drive my new business.....

Ibrahim

Change History (1)

comment:1 by Russell Keith-Magee, 11 years ago

Resolution: needsinfo
Status: newclosed

Ok - somewhere you've gotten terribly confused.

For starters, *none* of the code you've referenced should be contained in settings.py. As far as I can make out, the documentation pretty clearly says you should be editing polls/admin.py.

Secondly, I can't find anywhere in the tutorial where underscores are missing from example code. If you've used cut and paste as you describe, then something is going very wrong with your cut and paste.

If you're new to programming, I'd also suggest that you spend a little more time running a Python tutorial before you dig into Django. In Python, whitespace is significant. The level of indentation matters. Some code editors might be "helpful" and change indentation when you cut and paste code, and this will make a big difference when your code is executed.

You've obviously had problems with the tutorial, so we'd like to understand the source of your confusion. However, we're not mind readers. We need specifics. If you're saying "the code" tells you to use spaces instead of underscores, you'll need to provide specifics. If you think you've written the code exactly as the tutorial describes, then it would be helpful to see the code you've ended up with, so we can see what you think following the instructions means, and then we can judge where you've gone off course. Like I said, the code in the tutorial has been used successfully by many people, so we're fairly certain the code is correct, as long as the instructions are followed as intended. We can always improve those instructions, but we need to know where the confusion lies before we can improve anything.

Again, I'm closing this ticket needsinfo; Please, reopen *THIS* ticket if you have more information to provide.

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