Additional, dynamic fields for all Django models.
Project description
This module offers an easy way to attach auxiliary information to Django models. It allows configuring custom forms through the administration interface.
Usage
Add "specifications" to INSTALLED_APPS.
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.
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"]
Inherit from FormWithSpecification when creating your ModelForm:
from specifications.forms import FormWithSpecification class MyObjectForm(FormWithSpecification): class Meta: model = MyObject
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
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74c968304a508a23b9ea5f4c6eb837cfe8d492d8059c5a196f1d857b9b5c6423 |
|
MD5 | 25c42d7dc9582b48592ab340faccd9af |
|
BLAKE2b-256 | f601063582bd6b5b6c5141e365021745636cde7339b5df96eb56e16df6c724ca |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2568793bf709df37402d017b6675711a9cc08b928a0fa287877244a896b46486 |
|
MD5 | a3c62e753947441f579995aedcbcb1e1 |
|
BLAKE2b-256 | 0ba8725caca328299f64a7c78757fb7415a5c9b4c64fe11ff335bdd621a3a3b9 |