老师您好,最近开发过程中遇到了一个问题,修改面试信息时触发的,请您帮忙看一下,我自己暂时没有思路。
TypeError at /admin/interview/candidate/
Tried to update field interview.Candidate.creator with a model instance, <SimpleLazyObject: <User: admin>>. Use a value compatible with CharField.Request Method:POST
Request URL:http://127.0.0.1:8000/admin/interview/candidate/
Django Version:3.1.5
Exception Type:TypeError
Exception Value:Tried to update field interview.Candidate.creator with a model instance, <SimpleLazyObject: <User: admin>>. Use a value compatible with CharField.
Exception Location:D:\admin-management\recuitment\venv\lib\site-packages\django\db\models\sql\compiler.py, line 1485, in as_sql
Python Executable:D:\admin-management\recuitment\venv\Scripts\python.exe
Python Version:3.7.9
Python Path:['D:\\admin-management\\recuitment',
'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37\\
展开
作者回复: 提示类型不兼容。 可以对比一下跟Gitee仓库的代码有什么差别
小田君
2020-10-30
分享一个骚方法,直接在__init__.py文件里面设置导入local还是prod:
from .base import *
try:
from .local import *
live = False
except ImportError:
live = True
if live:
from .production import *
当然前提还是local.py这个文件在.gitignore和.dockerignore中,这样部署后import时一定会有imporError,然后就导入production的设置。