tags:

views:

89

answers:

3

I am using the following code and geting some indentation problem

from django.db import models

class Poll(models.Model):
    question = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

    def __unicode__(self):
        return self.question

I am geting following error

File "E:\Softwares\Django-1.1.1.tar\.py", line 7
    def __unicode__(self):
    ^
IndentationError: unexpected indent
+3  A: 

Most likely you're using a mix of tabs and spaces in your indentation... Use all spaces / all tabs instead. (The most widely adopted style is to use 4 spaces per level of indent.)

To fix this particular instance of the problem, check make the def __unicode__(self): line start with the same indent as the pub_date = ... line. Use the same indent + four extra spaces for the return ... line.

Michał Marczyk
And a good way to find out is to run the script with `python -tt`.
Ignacio Vazquez-Abrams
thnaks.I solved the problem using ur answer
You're welcome. :-) @Ignacio: Thanks for adding the good tip!
Michał Marczyk
+1  A: 

agree with the others, and you can use editor that can visualize the space to check. e.g. vim set list listchars=tab:»·,trail:· (gedit also has such plugins, i think).

Dyno Fu
These are some seriously cool listchars! +1 for the idea. :-)
Michał Marczyk
A: 
balpha