Alejandro A
Alejandro A

Reputation: 1190

IdentationError: Unexpected indent following Django Tutorial

I'm following the tutorial on django on the following link:

https://docs.djangoproject.com/en/1.11/intro/tutorial02/

Specifically the part where its adding the str methods on both classes, but I'm getting the indent error!

I used python before and after looking for a while I still can't see my error!

See the image with the hidden characters of my code, what is it!? It's been driving me crazy:

Error on django

See the error when trying to run the python shell:

Error on shell

So what could it be? I am legit running out of ideas.

Thank you!

Upvotes: 0

Views: 464

Answers (1)

Dan-Dev
Dan-Dev

Reputation: 9430

From the Python documentation https://docs.python.org/3/reference/lexical_analysis.html

Indentation is rejected as inconsistent if a source file mixes tabs and spaces in a way that makes the meaning dependent on the worth of a tab in spaces; a TabError is raised in that case.

if you are consistent in your use of tabs and spaces this problem will go away.

Upvotes: 1

Related Questions