Skip to content

Instantly share code, notes, and snippets.

@jbbarth
Last active May 28, 2018 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbbarth/b2406f226748ba2fc960722604170ee8 to your computer and use it in GitHub Desktop.
Save jbbarth/b2406f226748ba2fc960722604170ee8 to your computer and use it in GitHub Desktop.
class PirateForm(ModelForm):
class Meta:
model = Pirate
fields = ("name", "is_captain")
def __init__(self, *args, **kwargs):
user = kwargs.pop("user", None)
super().__init__(*args, **kwargs)
if not user:
del self.fields["is_captain"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment