-3

This is my code :

from django.db import models
from django.contrib.auth.models import User

class Post(models.Model):

    STATUS_CHOICES = (
        ('draft','Draft'),
        ('published','Published'),
    )

    title               =       models.CharField(max_length=100)
    slug                =       models.SlugField(max_length=120)
    author              =       models.ForeignKey(User, related_name='chat_posts')
    body                =       models.TextField()
    created             =       models.DateTimeField(auto_now_add=True)
    updated             =       models.DateTimeField(auto_now=True)
    status              =       models.CharField(max_length=10, choices=STATUS_CHOICES, default='draft')


   def __str__(self):
       return self.title

and the problem is with

File "C:--------------------------\models.py", line 20 def str(self):

IndentationError: unindent does not match any outer indentation level for str

Can someone help me with this?

Masoud Rahimi
  • 5,785
  • 15
  • 39
  • 67
KobbyLV
  • 9
  • 2

1 Answers1

1

The code inside your class is indented 4 spaces; until the def statement which is indented 3 spaces. That's not valid Python: it must be 4 spaces (to match the current indentation level) or no spaces (to match the outer indentation level, at class).

BoarGules
  • 16,440
  • 2
  • 27
  • 44