Django: I cant create a model, I got this error:[pylint] E0001:invalid syntax (<string>, line 8)

Django: I cant create a model, I got this error:[pylint] E0001:invalid syntax (<string>, line 8)

file: models.py

from __future__ import unicode_literals
from django.db import models

class Register(models.Model):
    name =models.Charfield(max_length = 100,blank=True,null=True)
    email =models.EmailField()
    timestamp = models.DateTimeField(auto_now_add=True,auto_now=False)

    def__unicode__(self):
        return self.mail

    def__str__(self): 
        return self.mail

Details:

您在 def 之后缺少空格。

def __unicode__(self):
    return self.mail

def __str__(self): 
    return self.mail

请注意,您根本不应该定义 __unicode__,它不会在 Python 中使用 3.