Login

Snippets by alfonsopalomares

Snippet List

ChoiceField with widget in choice

This code creates a widget that we used to generate a list of radiobuttons as follows: * Radio button 1 --Widget__1 * Radio button 2 --Widget__2 * Radio button 3 --Widget__3 How to use it is: `ImagenForm class (forms.ModelForm): widget1 = forms.BooleanField () widget2 = forms.TextInput widget3 = forms.ModelChoiceField (queryset = Modelo.objects.all ()) widget4 = forms.FileInput optConListas = ChoiceWithOtherField (choices = [(2, 'widget1' widget1), (3, 'widget2' widget3.widget), (4, "widget2" widget2), (5, 'widget4' widget4)])`

  • django
  • choice
  • choicefield
  • widget
  • alfonso
Read More

alfonsopalomares has posted 1 snippet.