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
- ExtendibleModelAdminMixin by dokterbob 3 years, 6 months ago
- GeoDjango maps in admin TabularInlines by alanB 2 years, 7 months ago
- SnippySnip by youell 4 years, 10 months ago
- RequestFetchingMixin by eternicode 2 years, 3 months ago
- Dynamically insert or append a value to an admin option, e.g. list_display or list_filter by frankban 1 year, 9 months ago
Comments