0
ipdb 디버그 :장고 : 다른 클래스의 객체를 반환 저장에 ModelForm
ipdb> form_class
<class 'myproject.apps.usersites.forms.IndividualSiteHomeForm'>
ipdb> form = form_class(request.POST)
ipdb> form
<myproject.apps.usersites.forms.IndividualSiteHomeForm object at 0x021A81F0>
ipdb> var = form.save(commit= False)
ipdb> var
<IndividualProfile: user1>
ipdb> request.POST
<QueryDict: {u'csrfmiddlewaretoken': [u'208ff2a5a78bd5c2ba9452b365b59b6d'], u'ho
me_content': [u'Some contents']}>
내가 데이터를 게시하는 것이 바인딩 후 IndividualSiteHomeForm을 저장하고있다. 왜 IndividualProfile 객체를 반환합니까? 참고로
: 1> 모델의 시간에 대한
class IndividualSite(SiteBase):
individual = models.ForeignKey(IndividualProfile, unique=True, verbose_name = _("Professional"))
logo = models.ImageField(upload_to="sites/logos/",verbose_name=_("logo"))
home_content = models.TextField(_("Home contents"), null=True, blank=False,
help_text = "This text will appear on your web site home. Do not use HTML here.")
def __unicode__(self):
return self.individual.name
2> ModelForm
class IndividualSiteHomeForm(ModelForm):
class Meta:
model = IndividualSite
exclude = ('individual','user','logo')
감사합니다.
편집 : VAR를 확인하려면 참으로 IndividualProfile입니다 :
ipdb> var
<IndividualProfile: user1>
ipdb> var.home_content
*** AttributeError: 'IndividualProfile' object has no attribute 'home_content'
ipdb> var.__class__
<class 'profiles.models.IndividualProfile'>
ipdb>
나는 IndividualProfile 개체입니다. EDIT를 참조하십시오. – trappedIntoCode