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 object 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.8.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

django_composite_field-0.8.0-py2.py3-none-any.whl (11.2 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for django-composite-field-0.8.0.tar.gz
Algorithm Hash digest
SHA256 80b44b712a9a2fe211866dd601ed74d7365f9dfb187df8c09655d9e95eecdf1f
MD5 d7e4ddd7704f5e02b1bac2642406b5a5
BLAKE2b-256 3b9fa2042183527d6663e1e608aa6d000967b1fcca6b2719d4ee3c32e7c5f543

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_composite_field-0.8.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b6607a292bde4f16ba4e78196fbbd1f7a2f708a971903a70fbf607993144532f
MD5 afeb7608ff7199e55a3d6f62f208b2ae
BLAKE2b-256 6b225ceda73edaf62397e4870b312188da4022c15260b7afe8ed774a2ae35bdb

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