Skip to main content

hide fields in django admin

Project description

django-hidefield

Provides a field base class to hide fields in django admin. The class turns a field label in an admin edit form into a show/hide toggle link.

Tested with Django 4.2.

Installation

  • pip install django-hidefield
  • place 'hidefield' in INSTALLED_APPS

Usage

Build a custom field class for any model field type you want to hide. The field has an additional argument hide with the following meaning:

  • 'closed' : the field is hidden at start
  • 'data' : the field is hidden at start, if the field contains data (default)
  • 'no-data' : the field is hidden at start, if the field contains no data
  • 'opened' : (or any other value) the field is shown at start

Example

from django.db import models
from hidefield.fields import HideField


class HideCharField(HideField, models.CharField):
    pass


class MyModel(models.Model):
    name = HideCharField(max_length=32, hide='data')

See exampleapp for more examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-hidefield-0.2.0.tar.gz (4.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page