Reputation: 101
Can I get a form into Django Administrator page, that I have defined in forms.py? Can I also get this form into Model inlines of Django Administrator page ?
To be clear, this is what I call inline:
class AnswerInline(admin.StackedInline):
...
Upvotes: 10
Views: 14322
Reputation: 21002
Yeah, it's a bit complicated but the docs are actually clear here:
InlineModelAdmin.form
The value for form defaults to ModelForm. This is what is passed through to inlineformset_factory when creating the formset for this inline.
So create your form class and then refer to it in the inline, like so:
class MyForm(forms.ModelForm):
…
class AnswerInLine(admin.StackedInline):
form = MyForm
Upvotes: 11