创建我的第一个Django应用程序

2024-05-19 11:03:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我的代码是:

from django.db import models
from django.utils.encoding import smart_unicode

class SignUp(models.Model):
    first_name = models.CharField(max_length=120, null=True, blank=True)
    last_name = models.CharField(max_length=120, null=True, blank=True)
    email = models.EmailField()
    timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
    updated = models.DateTimeField(auto_now_add=False, auto_now=True)


   def __unicode__(self):
        return smart_unicode(self.email)

这是我得到的。请帮忙谢谢你

^{pr2}$

缩进错误:未缩进与任何外部缩进级别都不匹配


Tags: djangonamefromimporttrueautosmartmodels
1条回答
网友
1楼 · 发布于 2024-05-19 11:03:45

timestamp前面有一个制表符。您应该使用空格或制表符来缩进Python,而不是两者都使用。您的编辑器可能会显示正确的缩进,但可能与Python理解制表符的方式不匹配。在

PEP-8表示只使用空格。在

相关问题 更多 >

    热门问题