0

我在 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

如何提取初始值?

4

1 回答 1

0

form.initials['placeholder'] 工作正常

于 2013-08-29T13:53:50.697 回答