Unicode Str error [Beginner question]

37 views
Skip to first unread message

Lian Tombing

unread,
Jul 3, 2014, 3:08:42 PM7/3/14
to django...@googlegroups.com
When I tried to implement the example, 
class Poll(models.Model):
    # ...
    def __unicode__(self):  # Python 3: def __str__(self):
        return self.question
I get the error,

Tab error: inconsistent use of tabs and spaces.

If I put def __str__ (self): 
in the same tab as class, it does not serve the purpose. Any help?

José Javier Castro Matamoros

unread,
Jul 3, 2014, 4:01:50 PM7/3/14
to django...@googlegroups.com
Could you please put all the code of the model.
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e5b59978-0f33-43ec-b3fc-ae398dab8770%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Jorge Andrés Vergara Ebratt

unread,
Jul 3, 2014, 4:59:56 PM7/3/14
to django...@googlegroups.com

Def __str__ is a comment, you can ommit it

Tom Evans

unread,
Jul 4, 2014, 4:33:15 AM7/4/14
to django...@googlegroups.com
On Thu, Jul 3, 2014 at 8:08 PM, Lian Tombing <lya...@gmail.com> wrote:
> When I tried to implement the example,
>
> class Poll(models.Model):
> # ...
> def __unicode__(self): # Python 3: def __str__(self):
> return self.question
>
> I get the error,
>
> Tab error: inconsistent use of tabs and spaces.

You must use either tabs or spaces to indent your code, not both tabs
and spaces. Configure your editor to output spaces instead of tab when
you press the tab key, and reindent your code.

Cheers

Tom
Reply all
Reply to author
Forward
0 new messages