[Answer]-Django tutorial: unexpected indent error

1👍

✅

Watch/Fix your indentation on the model method level:

from django.db import models
# Create your models here.

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

    # HERE 
    def __str__(self):
        return self.question


class Choice(models.Model):
    poll = models.ForeignKey(Poll)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)

    # AND HERE
    def __str__(self):
        return self.choice_text

Leave a comment