Skip to main content

django-enummodel

django-enummodel is a small utility application designed to help bridge the niche use case(s?) between defining enumerations for a given field (mutually exclusive options) and fully specifying non-exclusive options as instances of a fully specified model type.

In the common case, non-mututally exclusive options configured as a fully specified model (along with a fixture to store those options) can, in the best case, ‘just work’; in the worst case, it can provide mild headaches, notably when lazy translations are involved.

In the particular case of the author, the challenge was to avoid having to cope with a O(n) growth rate of fixtures to manage, coupled with the desire to avoid encountering issues of internationalization and being forced to choose a particular character set in which to store these values.

django-enummodel provides a Django Model object with which the developer may extend to provide the functionality sketched above:

LANGUAGE_CHOICES = (
    (1,_(u'English')),
    (2,_(u'Spanish')),
    (3,_(u'French')),

    (255,_(u'other')),
)

class Language(EnumModel):
    class EnumMeta:
        choices = LANGUAGE_CHOICES

Please note that that population of any model derived from EnumModel takes place after schema migration; therefore, changes to the choices basis will need to be rectified by running:

django-admin.py migrate

or:

django-admin.py migrate app_name

Metadata

Release files for django-enummodel 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-enummodel 0.2.1
File Size Uploaded
django-enummodel-0.2.1.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-enummodel 0.2.1
File Interpreter ABI Platform
django_enummodel-0.2.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 16.2 kB

Release files / django-enummodel-0.2.1.tar.gz

Download URL django-enummodel-0.2.1.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4ad287502bba15612bb91195b770d858cac3f8ea42ec40543737145a1032e53a
BLAKE2b-256 checksum
How to use checksums
9f5d72a4b125da59c81eca0c9b0ffa270a48cbc8324cd7adb7fc74b529219c75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_enummodel-0.2.1-py2.py3-none-any.whl

Download URL django_enummodel-0.2.1-py2.py3-none-any.whl
Size 10.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
0286f1dc509d5aa05f5f6caf1fa98a18f8efa8094122b63c9256f9365ddf88f8
BLAKE2b-256 checksum
How to use checksums
f242dd46c4451c8a49d4d7b6047b38af41f8e4b9006d3fe624f5801079566662
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page