Skip to main content

Additional, dynamic fields for all Django models.

Project description

=====================
django-specifications
=====================

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

Version |release|

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):
def get_fieldsets(self, request, obj=None):
# Define your fieldsets
fieldsets = [...]
if self.can_add_specification_fields(request, obj):
# Extend your fieldset with specification fields
fieldsets.extend(...)
return fieldsets

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.3.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_specifications-0.3.0-py2.py3-none-any.whl (13.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-specifications-0.3.0.tar.gz.

File metadata

  • Download URL: django-specifications-0.3.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for django-specifications-0.3.0.tar.gz
Algorithm Hash digest
SHA256 59d40c0cfce1c12136d71a55556b17b890b3ee0a823f6d0f5af5b1240d188da8
MD5 2f7ce3eeb1617884990435e978f9e71d
BLAKE2b-256 6eb893b5e946f6b339945473ad07512f6f27a11b187da68f06a01806ad49cad3

See more details on using hashes here.

File details

Details for the file django_specifications-0.3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: django_specifications-0.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for django_specifications-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b69ed7344646c1af2333ebabfb2280ff7bfb33914b0fd4ce0ca9309c9047c008
MD5 2cc16ed979326b6e54b7cb26d1c7c1f2
BLAKE2b-256 706fac5018521fdaad3bcc4e68fd08d85f24cd6253d49d15d6a84f8573e4679f

See more details on using hashes here.

Supported by

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