Opened 7 years ago

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



I'm new to Django and Python and was following the steps in the tutorial:

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.



Change History (1)

comment:1 Changed 7 years ago by Aymeric Augustin

Resolution: worksforme
Status: newclosed

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