Skip to content

Instantly share code, notes, and snippets.

@hirokts
Last active May 10, 2017 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hirokts/7953c8ffb046d7a17aeba87ff38f2b1d to your computer and use it in GitHub Desktop.
Save hirokts/7953c8ffb046d7a17aeba87ff38f2b1d to your computer and use it in GitHub Desktop.
djangoでchoicefield(セレクトボックス)を含むformのformsetを使う場合の選択肢の注入のパターン(form)
class ArticleSelectForm(forms.Form):
title = forms.CharField(
widget=forms.TextInput(attrs={'placeholder': _(u'内容'), 'size': 60, }),
)
article_group = forms.ChoiceField(
widget=forms.Select(),
choices=[],
required=False,
)
ArticleSelectFormSet = formsets.formset_factory(ArticleSelectForm, extra=1, max_num=100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment