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

Uploaded Source

Built Distribution

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

django_composite_field-0.7.1-py2.py3-none-any.whl (9.0 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

File hashes

Hashes for django-composite-field-0.7.1.tar.gz
Algorithm Hash digest
SHA256 b161e453ecf54c11921f45b7ae81a17813cf1cf89a07ca83cc803e103038528a
MD5 cecb82a45e9a0a6e23ac598e9b6a604d
BLAKE2b-256 9eb44467036f8d395520ebade94eb13410e2298440fb03de73c1a84ae829d8d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_composite_field-0.7.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3ff811a2d05fd40d7260a318a074b78f1a3731b94b6fa81fddf56724f157d3cc
MD5 84facec04a36c54a6d4bec6ae09a4359
BLAKE2b-256 ca636f5b8d48d5535622a7896b1954694eb7d3dd3d1e6dd0d1848056a796dee3

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