0
의 일환으로 나열되지 않은 DB 필드에 데이터를 저장하는 방법.내가 로그인 한 사람의 이메일 주소로 <strong>Mstrstorehead-CONTACTEMAIL</strong>에 노력하고 어디는 <code>CreateView</code> 다음 한 장고 CreateView
문제는 필드 중 하나가 CreateView
양식에 표시되는대로 CONTACTEMAIL 목록에없는 것입니다
(MstrstoreheadCreate
인)이 필드는 어떻게 할당 내가받을 수 있나요?
views.py
class MstrstoreheadCreate(CreateView):
model = Mstrstorehead
fields = ['companyname',
'taxeinno', 'companyname', 'abanumber', 'businesstypeid', 'ourmission', 'contactsalutationid',
'contactfirstname', 'contactlastname', 'contactofficephoneno', 'contactcellphoneno' ]
template_name_suffix = '_mstr_create_form'
def form_valid(self, form):
mhead = form.save(commit=False)
mhead.contactemail = self.request.user.email << contactemail is part of the model but NOT part of the fields used in CreateView
return super(MstrstoreheadCreate, self).form_valid(form)
TIA
보기 (당신이 처리하는 하나의 형태)에