from django.db import models
class Category(models.Model):
title = models.CharField(max_length=250)
slug = models.SlugField(unique=True)
description = models.TextField()
class Meta:
verbose_name_plural = "Categories"
def __unicode__(self):
return self.title
我收到此错误
verbose_name_plural = "Categories" ^ IndentationError: expected an indented block
我使用gedit使用空格作为选项卡的选项(也尝试更改标签宽度)..我几乎可以肯定代码是正确的..但是间距和标签有些问题..
答案 0 :(得分:5)
class Meta:
verbose_name_plural = "Categories"
class Meta:
后,您没有正确缩进。
答案 1 :(得分:3)
应该是
from django.db import models
class Category(models.Model):
title = models.CharField(max_length=250)
slug = models.SlugField(unique=True)
description = models.TextField()
class Meta:
verbose_name_plural = "Categories"
def __unicode__(self):
return self.title
由于预期verbose_name_plural
位于class Meta
,因此应该考虑它。