forms.py
789 Bytes
# -*- coding: utf-8 -*-
from django.utils.translation import ugettext as _
from django import forms
def hidden_id(id):
return forms.CharField(initial=id, widget=forms.HiddenInput())
# https://djangosnippets.org/snippets/2400/
def remove_holddown(form, fields):
"""This removes the unhelpful "Hold down the...." help texts for the
specified fields for a form."""
remove_message = unicode(
_('Hold down "Control", or "Command" on a Mac, to select more than one.'))
for field in fields:
if field in form.base_fields:
if form.base_fields[field].help_text:
form.base_fields[field].help_text = \
form.base_fields[field].help_text.replace(
remove_message, '').strip()
return form