Skip to content

Instantly share code, notes, and snippets.

@jbbarth
Last active May 28, 2018 08:23
Show Gist options
  • Save jbbarth/ff8c7add0c4adeed9376bf81476466e5 to your computer and use it in GitHub Desktop.
Save jbbarth/ff8c7add0c4adeed9376bf81476466e5 to your computer and use it in GitHub Desktop.
{# Keep this condition in sync with PirateForm #}
{% if user.name == "Alice" %}
<input type=checkbox name=is_captain id=id_is_captain {% if object.is_captain %}checked{% endif %}>
{% else %}
class PirateForm(ModelForm):
...
def __init__(...):
# fields restriction
# should be kept in sync with the template form.html
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