Skip to main content

CompositeField implementation for Django

Project description

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

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

There are some more examples in the included tests.py.

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-composite-field-0.7.6.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

django_composite_field-0.7.6-py2.py3-none-any.whl (10.2 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for django-composite-field-0.7.6.tar.gz
Algorithm Hash digest
SHA256 3d34ee6362651700f7e7f4016aa91110840d6b38cef8e1a2bae7ed648c7d0ab5
MD5 5deb20a6cc21430362b9e349e9459ce4
BLAKE2b-256 3a8824d2048655f48267b7522f9200460ab6b9ef538328319535abf6723f735e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_composite_field-0.7.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7fec0e6428e73756cdeabcd179c3f71a41159706e719bc75e38f4b96c3db151b
MD5 90a670d5ce6e261964eb54b32d9149bd
BLAKE2b-256 b57092f8b2bacba93a1dde0630e7eff2d112de938d92fda3c24c9a89aae04dc2

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