这是我的代码
from __future__ import unicode_literals
from django.db import models
# Create your models here.
class Post(models.Model):
title = models.CharField()
content = models.CharField()
updated = models.DateTimeField(auto_now=True, auto_now_add=False)
timestamp = models.DateTimeField(auto_now=False,auto_now_add=True)
def __unicode__(self): #
return self.title
def __str__(self):
return self.title
答案 0 :(得分:0)
缩小你的定义,如下:
def __unicode__(self): #
return self.title
def __str__(self):
return self.title
答案 1 :(得分:0)
在函数之后,期望缩进块
def __unicode__(self): #
return self.title
错误的正确方法是
def __unicode__(self): #
return self.title