Opened 3 years ago

Closed 3 years ago

#19012 closed Uncategorized (worksforme)

Spaces instead of tabs

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

Description

Hi,

I'm new to Django and Python and was following the steps in the tutorial: https://docs.djangoproject.com/en/1.4/intro/tutorial01/

I edited the models file to create the Polls and Choices and added the poll, but when I got to the section that starts:

class Poll(models.Model):

# ...
def unicode(self):

return self.question

I was unsure of where to add the method, also when I pasted the code into the text editor I'm using, it pastes the indents as spaces, it took me a search to find out that indents were important.

Could you replace the example spaces with tabs so that the example works straight away? This may help other python newbies like myself.

Thanks,

Adam

Change History (1)

comment:1 Changed 3 years ago by aaugustin

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

The style guide for Python code (PEP8) recommends indenting with 4 spaces, and this convention is used throughout Django's code and documentation. This isn't going to change.

Copy-pasting this code snippet respects the indents for me, and it works without any further changes.

Your editor might improperly attempt to auto-indent pasted code (for instance vim suffers from this problem if you forget to enter paste mode).

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