Hello! I’m still pretty new to Django, and would like to replace the default “-------” in a ModelChoiceField in a ModelForm. The docs state I need to set the
However, I’m having trouble figuring out how to write the required queryset argument. Here is my code so far…
class InternalExternal(models.TextChoices): INTERNAL = "internal" EXTERNAL = "external" class Clients(models.Model): internal_external = models.CharField( "internal/external group", choices=InternalExternal.choices, help_text="A group is either internal or external to your organization", max_length=25, )
class FooCreateForm(ModelForm): internal_external = ModelChoiceField(queryset=Clients.objects.???, empty_label="select a value") class Meta: fields = ("internal_external") model = Clients
I’ve tried numerous things, but I can’t figure out what to plug in as a queryset to (essentially) provide the contents of my
InternalExternal class. I’m very new to Querysets, and the surface area of the AP is rather immense!
Additionally, is there a good (clean) way to replace the “-----” items for all the ModelChoiceFields in my project (an override of some sort)? Any help would be greatly appreciated!