储蓄。 Error has been deleted. 保存的 错误已被删除。 错误已被隐藏。
错误
标题
我收到一个错误
文件“ /home/sandeep/my-django/mysite/blog/models.py”,第8行
(auto_now_add =真)
^
SyntaxError:语法无效



Creating-Django-Models 04-05 min 0-10 sec Python-Django 创建-Django模型 04-05分钟 0-10秒 28-08-19,下午6:01 sandeepbvjniot@gmail.com

答案:

请共享models.py的完整代码
pravin1389,上午 29-08-19 ,上午 10:22

-------------------------------------------------- ------------------------------
追溯(最近一次通话):
<模块>中第21行的文件“ manage.py”
主要()
主文件第17行中的文件“ manage.py”
execute_from_command_line(sys.argv)
第381行中的文件“ /home/sandeep/my-django/myapp_env/lib/python3.6/site-packages/django/core/management/__init__.py”,在execute_from_command_line中
utility.execute()
在执行中的文件“ /home/sandeep/my-django/myapp_env/lib/python3.6/site-packages/django/core/management/__init__.py”,第357行
django.setup()
在设置中,文件“ /home/sandeep/my-django/myapp_env/lib/python3.6/site-packages/django/__init__.py”
apps.populate(settings.INSTALLED_APPS)
填写文件“ /home/sandeep/my-django/myapp_env/lib/python3.6/site-packages/django/apps/registry.py”,第114行
app_config.import_models()
在import_models中的文件“ /home/sandeep/my-django/myapp_env/lib/python3.6/site-packages/django/apps/config.py”中,第211行
self.models_module =导入模块(models_module_name)
import_module中的文件“ /usr/lib/python3.6/importlib/__init__.py”,行126
返回_bootstrap._gcd_import(name [level:],包,级别)
_gcd_import中的文件“ <frozen importlib._bootstrap>”,行994
_find_and_load中的文件“ <frozen importlib._bootstrap>”,第971行
_find_and_load_unlocked中的文件“ <frozen importlib._bootstrap>”,第955行
_load_unlocked中的第665行的文件“ <frozen importlib._bootstrap>”
exec_module中的文件“ <frozen importlib._bootstrap_external>”,行674
get_code中的文件“ <frozen importlib._bootstrap_external>”,行781
source_to_code中的第741行的文件“ <frozen importlib._bootstrap_external>”
_call_with_frames_removed中的文件“ <frozen importlib._bootstrap>”,第219行
文件“ /home/sandeep/my-django/mysite/blog/models.py”,第8行
(auto_now_add =真)
^
SyntaxError:语法无效
-------------------------------------------------- --------------------------

从django.db导入模型

#在此处创建模型。

类Blog(models.Model):
<span style =“ white-space:pre”> \\ t </ span> name = models.CharField(max_length = 120)
<span style =“ white-space:pre”> \\ t </ span> created_on = models.DateTimeField
(auto_now_add =真)

类Article(models.Model):
<span style =“ white-space:pre”> \\ t </ span> blog = models.ForeignKey(Blog,on_delete = models.CASCADE)
<span style =“ white-space:pre”> \\ t </ span> created_on = models.DateTimeField
(auto_now_add =真)
<span style =“ white-space:pre”> \\ t </ span> title = models.CharField(max_length = 120)
<span style =“ white-space:pre”> \\ t </ span> body = models.TextField()
<span style =“ white-space:pre”> \\ t </ span>草稿= models.BooleanField(default = False)
29-08-19,10:31 am sandeepbvjniot@gmail.com
从django.db导入模型

#在此处创建模型。

类Blog(models.Model):
<span style =“ white-space:pre”> \ t </ span> name = models.CharField(max_length = 120)
<span style =“ white-space:pre”> \ t </ span> created_on = models.DateTimeField
(auto_now_add =真)

类Article(models.Model):
<span style =“ white-space:pre”> \ t </ span> blog = models.ForeignKey(Blog,on_delete = models.CASCADE)
<span style =“ white-space:pre”> \ t </ span> created_on = models.DateTimeField
(auto_now_add =真)
<span style =“ white-space:pre”> \ t </ span> title = models.CharField(max_length = 120)
<span style =“ white-space:pre”> \ t </ span> body = models.TextField()
<span style =“ white-space:pre”> \ t </ span>草稿= models.BooleanField(default = False)
29-08-19,10:34 am sandeepbvjniot@gmail.com

登录以添加评论


请参见以下代码:
-------------------------------------------------- -----------
从django.db导入模型

#在此处创建模型。

类Blog(models.Model):
<span style =“ white-space:pre”> \ t </ span> name = models.CharField(max_length = 120)
<span style =“ white-space:pre”> \ t </ span> created_on = models.DateTimeField
(auto_now_add =真)

类Article(models.Model):
<span style =“ white-space:pre”> \ t </ span> blog = models.ForeignKey(Blog,on_delete = models.CASCADE)
<span style =“ white-space:pre”> \ t </ span> created_on = models.DateTimeField
(auto_now_add =真)
<span style =“ white-space:pre”> \ t </ span> title = models.CharField(max_length = 120)
<span style =“ white-space:pre”> \ t </ span> body = models.TextField()
<span style =“ white-space:pre”> \ t </ span>草稿= models.BooleanField(default = False)
-------------------------------------------------- ------------------------
29-08-19,10:35 am sandeepbvjniot@gmail.com


登录以回答这个问题。