i have this code from the django sample tutorial
from django.db import models
from datetime import datetime
# Create your models here.
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
def was_published_today(self):
return self.pub_date.date() == datetime.date.today()
and i am getting this error: IndentationError: unexpected indent
on this line:
def __unicode__(self):
any idea what is wrong ??
My only guess is you have tabs mixed with spaces.
It's recommended to use spaces over tabs, with 4 spaces per indentation. http://www.python.org/dev/peps/pep-0008/
Do you have invisible characters visible on your editor to make sure that isn't the case?
PS: your reputation graph says -6000 and it's really bugging me out.
Probably this is because you did copy/paste from the tutorial. Pay special attention to the tabs and spaces.
Hope it helps.
Sometimes it can be hard work with big files to find where error is, so you can install pep8 http://pypi.python.org/pypi/pep8 module and use it from command line
$ pep8 a.py a.py:1:4: W191 indentation contains tabs a.py:1:4: E101 indentation contains mixed spaces and tabs a.py:1:5: E113 unexpected indentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With