1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # Django snippet 1803: http://djangosnippets.org/snippets/1803/
import logging
logger = logging.getLogger(__name__)
def remove_from_fieldsets(fieldsets, fields):
for fieldset in fieldsets:
for field in fields:
if field in fieldset[1]['fields']:
logging.debug("'%s' field found in %s, hiding." % (field, fieldset[1]['fields']))
newfields = []
for myfield in fieldset[1]['fields']:
if not myfield in fields:
newfields.append(myfield)
fieldset[1]['fields'] = tuple(newfields)
logger.debug('Setting newfields to: %s' % newfields)
break
|
More like this
- DRY Fieldsets by DrMeers 2 years, 11 months ago
- Initial values for new items in admin by RommeDeSerieux 2 years, 8 months ago
- ExtendibleModelAdminMixin by dokterbob 2 years, 6 months ago
- RequestFetchingMixin by eternicode 1 year, 4 months ago
- Form splitting/Fieldset templatetag by peritus 3 years, 8 months ago
Comments