Skip to main content

CompositeField implementation for Django

Project description

Build Status PyPI Version PyPI License Python Versions Django Versions Read the Docs

CompositeField for Django Models

This is an implementation of a CompositeField for Django. Composite fields can be used to group fields together and reuse their definitions.

Example

class CoordField(CompositeField):
    x = models.FloatField()
    y = models.FloatField()

class Place(models.Model):
    name = models.CharField(max_length=10)
    coord = CoordField()

p = Place(name='Foo', coord_x=42, coord_y=0)
q = Place(name='Foo', coord=p.coord)
q.coord.y = 42

How does it work?

The content of composite fields are stored inside the model, so they do not have to fiddle with any internals of the Django models. In the example above p.coord returns a proxy object that maps the fields x and y to the model fields coord_x and coord_y. The proxy object also makes it possible to assign more than one property at once.

Documentation can be found at RTFD.

Download files

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

Source Distribution

django-composite-field-1.1.0.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

django_composite_field-1.1.0-py2.py3-none-any.whl (11.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-composite-field-1.1.0.tar.gz.

File metadata

File hashes

Hashes for django-composite-field-1.1.0.tar.gz
Algorithm Hash digest
SHA256 9b6407742f179e2462ba36cbd3b124e0b1dca948c89a5a00f17747c33140eadd
MD5 6d69af5ba4d50e192586f619cae62373
BLAKE2b-256 77188844bee93e82d6615ec7944d5bdb8f9cc77e49210ecd733d76b06ed1b916

See more details on using hashes here.

File details

Details for the file django_composite_field-1.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_composite_field-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 afc75c6724a3a55e68d75edc8ab3fc3f3646986fc702a29d94f495571f381448
MD5 d5b6061c3f58b0c6cc7f63cd1c3cb397
BLAKE2b-256 f8bd2e85c83e986d994f36f946f739cb7f7e7d277b17bc79da8d9cfea73719d4

See more details on using hashes here.

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