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:
- 错误:[pylint] E0001:invalid word 中的语法(,第 8 行):class
- 我尝试执行命令行:
python manage.py makemigrations
- 消息是:未检测到任何更改。
- 我使用 python 3.7,sqllite,Django 2.0.1
您在 def
之后缺少空格。
def __unicode__(self):
return self.mail
def __str__(self):
return self.mail
请注意,您根本不应该定义 __unicode__
,它不会在 Python 中使用 3.
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:
- 错误:[pylint] E0001:invalid word 中的语法(,第 8 行):class
- 我尝试执行命令行: python manage.py makemigrations
- 消息是:未检测到任何更改。
- 我使用 python 3.7,sqllite,Django 2.0.1
您在 def
之后缺少空格。
def __unicode__(self):
return self.mail
def __str__(self):
return self.mail
请注意,您根本不应该定义 __unicode__
,它不会在 Python 中使用 3.