Skip to content

Instantly share code, notes, and snippets.

@elyssonmr
Created March 26, 2019 15:26
Show Gist options
  • Save elyssonmr/f893396ceae7fb802b20d58a63660808 to your computer and use it in GitHub Desktop.
Save elyssonmr/f893396ceae7fb802b20d58a63660808 to your computer and use it in GitHub Desktop.
class MyFormClass(forms.ModelForm):
def __init__(self, *args, **kwargs):
super()
pk = kwargs.pop("pk", None)
if pk:
self.field_with_querystring.query = Something.objects.filter(pk=pk)
form = MyFormClass(pk=client_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment