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

Uploaded Source

Built Distribution

django_composite_field-0.9.1-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.9.1.tar.gz.

File metadata

  • Download URL: django-composite-field-0.9.1.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for django-composite-field-0.9.1.tar.gz
Algorithm Hash digest
SHA256 5ee1ac8bc74a76a6657d732adf1f66ff90960cc52c8986bff4b1c0e2315be2ed
MD5 d708f4dc9895ba6ca46aa39960340a04
BLAKE2b-256 1d8e74f53c019a22d6b6f849f02a28d56e89eef752fa769f3aeb6fa11f88b5aa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_composite_field-0.9.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for django_composite_field-0.9.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1affafab7d78ea07be9bafc405dac9d14e9aab50bfa100757858c94355108fe6
MD5 fb392b398d226f025b94b3d0b9bd7962
BLAKE2b-256 2773e07edd80b0c633c9faae40126c91c4f49b6d7d2c8e4b2510a5363006d1f5

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