[Django] save() prohibited to prevent data loss due to unsaved related object
2019. 10. 14. 11:09ㆍTrouble Shooting
728x90
Internal Server Error: /customer/1
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.6/dist-packages/django/views/generic/base.py", line 69, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/django/views/generic/base.py", line 89, in dispatch
return handler(request, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/django/views/generic/edit.py", line 194, in post
return super().post(request, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/django/views/generic/edit.py", line 142, in post
return self.form_valid(form)
File "/car/crms/crm/customer/detail.py", line 283, in form_valid
config = self.alarm(r, counsel)
File "/car/crms/crm/customer/detail.py", line 251, in release_alarm
cc.save()
File "/usr/local/lib/python3.6/dist-packages/django/db/models/base.py", line 685, in save
"unsaved related object '%s'." % field.name
ValueError: save() prohibited to prevent data loss due to unsaved related object 'alarm'.
django value error
django 1.8.4에서 적용된 오류인데, 1.8.5에서는 넣다뺏다 지롤을 하네요
해당 에러는 관계형 DB에서 해당 테이블내에 초기화를 안해줘서 그렇답니다.
참고자료
그냥 default값을 create당시에 할당 해 주시면됩니다.
728x90
'Trouble Shooting' 카테고리의 다른 글
[aiohttp] 세마포 제한 시간이 만료되었습니다 (0) | 2019.12.04 |
---|---|
Django CSRF token missing or incorrect (0) | 2019.11.05 |
RequestsDependencyWarning: urllib3 (1.25.6) or chardet (3.0.4) doesn't match a supported version! RequestsDependencyWarning) (0) | 2019.09.26 |
Kali / Debian TeamViewer install error ... (0) | 2019.09.24 |
Nuxt.js / Vue.js 무한 새로고침 현상 (0) | 2019.08.23 |