Answer the question
In order to leave comments, you need to log in
How to set initial values in django inlines?
Prompt on a question.
there is a model:
class ProductTechInfo(models.Model):
"""техническая информация для продуктов
"""
product = models.ForeignKey(Product, verbose_name=_(u"товар"), related_name="techinfo")
name = models.ForeignKey(TechInfo, verbose_name=_(u"имя"), related_name="name")
value = models.TextField(_(u'значение'), blank=True)
class TechInfoForm(forms.ModelForm):
class Meta:
model = ProductTechInfo
fields = ("name", "value", )
widgets = {
'value': Textarea(attrs={'rows': 2}),
}
class ProductTechInfoInline(admin.TabularInline):
model = ProductTechInfo
form = TechInfoForm
extra = 2
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question