79275456

Date: 2024-12-12 14:24:22
Score: 1
Natty:
Report link

The templates field.html and fields.html got adjusted today, so they can also handle ChoiceField and ModelChoiceField properly by passing choices parameter:

https://github.com/pennersr/django-allauth/commit/1eac57caaab22d40b1df99b272b9f34c795212cc

Than it can be used like this:

class CustomUserCreationForm(forms.ModelForm):
    salutation = forms.ChoiceField(widget=Select(attrs={'placeholder': 'Salutation'}), choices=CustomUser.SALUTATION)
    country = forms.ModelChoiceField(widget=Select(attrs={'placeholder': 'Country'}), queryset=Country.objects.all())
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: CodeResearcher