Skip to content

Instantly share code, notes, and snippets.

@hseritt
Last active February 25, 2017 12:58
Show Gist options
  • Save hseritt/4dac1695b992915e0d066703c8d00111 to your computer and use it in GitHub Desktop.
Save hseritt/4dac1695b992915e0d066703c8d00111 to your computer and use it in GitHub Desktop.
Django forms - setting help text for fields
# In the __init__ method:
self.fields['description'].help_text = mark_safe(FIELD_REQUIRED_MSG)
self.fields['issue_type'].help_text = mark_safe(FIELD_REQUIRED_MSG)
self.fields['priority'].help_text = mark_safe(FIELD_REQUIRED_MSG)
self.fields['project'].help_text = mark_safe(FIELD_REQUIRED_MSG)
self.fields['title'].help_text = mark_safe(FIELD_REQUIRED_MSG)
# and in class Meta:
class Meta:
model = Contact
fields = ['user', 'bio', 'organization', 'phone_number', 'skype', 'google', 'image_file']
help_texts = {
'bio': 'Tell us what you do and how you got here.',
'user': 'Referred user must already exist in the system ' \
+ 'and not be assigned to an organization.'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment