我在models.py中有模型
class Page(models.Model):
url = models.CharField(verbose_name="url", unique=True, db_index=True, max_length=255)
template = models.ForeignKey(Template)
class PageToBlock(models.Model):
page = models.ForeignKey(Page)
placeholder = models.ForeignKey(Placeholder)
block = models.ForeignKey(Block,null=True)
以及视图中的一些代码
PTBFormSet = inlineformset_factory(models.Page, models.PageToBlock, extra=0, can_delete=False)
formset = PTBFormSet(instance=page)
for form in formset:
# i need initial here for processing
print form.fields['placeholder'].initial #print None!, but in final rendered form it has value
如何提取初始值?
答案 0 :(得分:0)
form.initials ['placeholder']工作正常