Skip to main content

Additional, dynamic fields for all Django models.

Project description

https://travis-ci.org/matthiask/django-specifications.png?branch=master

This module offers an easy way to attach auxiliary information to Django models. It allows configuring custom forms through the administration interface.

Usage

  1. Add "specifications" to INSTALLED_APPS.

  2. Create a specification = ForeignKey("specifications.Specification") on the model you want to use specifications with. The foreign key can be nullable or required, as you wish.

  3. Create the place where the specification field data is actually stored:

    from specifications.models import SpecificationValueFieldBase
    
    class MyObjectField(SpecificationValueFieldBase):
        parent = models.ForeignKey(
            MyObject,
            on_delete=models.CASCADE,
            related_name="fields",
        )
    
        class Meta:
            ordering = ["field__group__ordering", "ordering"]
  4. Inherit from FormWithSpecification when creating your ModelForm:

    from specifications.forms import FormWithSpecification
    
    class MyObjectForm(FormWithSpecification):
        class Meta:
            model = MyObject
  5. If you want to edit models with specifications you might want to use the following snippet:

    from specifications.admin import ModelAdminWithSpecification
    
    class MyObjectAdmin(ModelAdminWithSpecification):
        pass

The fields are available after saving a specification. The specification can be changed, but you risk losing data if you do this.

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_specifications-0.5.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

django_specifications-0.5.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file django_specifications-0.5.0.tar.gz.

File metadata

  • Download URL: django_specifications-0.5.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for django_specifications-0.5.0.tar.gz
Algorithm Hash digest
SHA256 74c968304a508a23b9ea5f4c6eb837cfe8d492d8059c5a196f1d857b9b5c6423
MD5 25c42d7dc9582b48592ab340faccd9af
BLAKE2b-256 f601063582bd6b5b6c5141e365021745636cde7339b5df96eb56e16df6c724ca

See more details on using hashes here.

Provenance

File details

Details for the file django_specifications-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: django_specifications-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for django_specifications-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2568793bf709df37402d017b6675711a9cc08b928a0fa287877244a896b46486
MD5 a3c62e753947441f579995aedcbcb1e1
BLAKE2b-256 0ba8725caca328299f64a7c78757fb7415a5c9b4c64fe11ff335bdd621a3a3b9

See more details on using hashes here.

Provenance

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