python Django 模型缩进错误
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 = "类别" ^ IndentationError:需要一个缩进块
我正在使用 gedit 并使用空格作为选项卡选项(也尝试更改选项卡宽度)..我几乎可以肯定代码是正确的..但是间距和选项卡存在一些问题..
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
I am getting this error
verbose_name_plural = "Categories" ^ IndentationError: expected an indented block
I am using gedit with use spaces as option for tabs ( also tried altering tab width)..I am almost certain that the code is correct..but some problem with spacing and tabs..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您在
class Meta:
之后没有正确缩进。You are not indenting correctly after
class Meta:
.它应该是
由于
verbose_name_plural
预计位于class Meta
中,因此应该识别它。it should be
Since
verbose_name_plural
is expected to be inclass Meta
, it should be idented.