Yes… From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of matteo gassend Sent: Monday, August 13, 2018 10:10 AM To: Django users Subject: Re: Select2 default value
Even for a Modelform? Il giorno lunedì 13 agosto 2018 17:08:35 UTC+2, Matthew Pava ha scritto: In Django forms, it’s called an initial value instead of a default value. https://docs.djangoproject.com/en/2.1/ref/forms/api/#django.forms.Form.initial From: django...@googlegroups.com<javascript:> [mailto:django...@googlegroups.com<javascript:>] On Behalf Of matteo gassend Sent: Monday, August 13, 2018 9:49 AM To: Django users Subject: Select2 default value Hey everyone, I am trying to set a default value for a Select2Widget(from django_select2) to use in a formset. I am able to set one for those added with js, but cannot set the one for the form already present. This is the form class Ddt_in_itemForm(forms.ModelForm): class Meta: model = ddt_in_item fields = ("prodotti_var", "quantita", "scade") widgets = { 'prodotti_var': Select2Widget() } def __init__(self, *args, **kwargs): super(Ddt_in_itemForm, self).__init__(*args, **kwargs) self.fields["scade"].required = False self.fields["prodotti_var"].queryset = prodotti.objects.filter(is_active=True).order_by('nome_prodotto') Can you guys help me? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com<javascript:>. To post to this group, send email to djang...@googlegroups.com<javascript:>. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/83b07178-66e1-419a-8f02-f7769db6d3f2%40googlegroups.com<https://groups.google.com/d/msgid/django-users/83b07178-66e1-419a-8f02-f7769db6d3f2%40googlegroups.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com<mailto:django-users@googlegroups.com>. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/246b9996-a9cc-435b-82b9-81b22304cb17%40googlegroups.com<https://groups.google.com/d/msgid/django-users/246b9996-a9cc-435b-82b9-81b22304cb17%40googlegroups.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a0651afd14a54d18898ae661e09426ac%40ISS1.ISS.LOCAL. For more options, visit https://groups.google.com/d/optout.