Skip to content

Instantly share code, notes, and snippets.

@andraantariksa
Created September 5, 2022 02:10
Show Gist options
  • Save andraantariksa/e524c2b7ba2044ecd71aeb16ce922f36 to your computer and use it in GitHub Desktop.
Save andraantariksa/e524c2b7ba2044ecd71aeb16ce922f36 to your computer and use it in GitHub Desktop.
class SomeTypedDict(TypedDict):
brands = forms.ModelChoiceField(required=True, queryset=None)
class MerchantBrandsForm(forms.Form, SomeTypedDict):
fields: SomeTypedDict
def __init__(self: merchant: Merchant, *args: Any, **kwargs: Any):
super().__init__(*args, **kwargs)
self.fields['brands'].queryset = merchant.brands.all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment