我在一个django应用程序中运行一个脚本,它位于app_name文件夹的根目录下;就像在app_name>;app_name中一样。在
在脚本的顶部我有这样的内容:
import os
import sys
os.environ.setdefault('DJANGO_SETTINGS_MODULE','versal.settings')
import django
django.setup()
我试图处理一个完整性错误-我的slug需要是唯一的,所以当一个不唯一时,我想通过在slug中添加一个'1'来处理完整性错误。在
^{pr2}$当我运行这段代码时,我得到:
Traceback (most recent call last):
File "podcasts.py", line 166, in <module>
podcasty()
File "podcasts.py", line 159, in podcasty
submit(podcast_objects,podcast_rss)
File "podcasts.py", line 73, in submit
except IntegrityError as e:
NameError: name 'IntegrityError' is not defined
您需要在使用它之前导入它。在
相关问题 更多 >
编程相关推荐