Skip to main content

CompositeField implementation for Django

Project description

CompositeField for Django Models

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

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.

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-2.0.1.tar.gz (14.1 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-2.0.1-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file django_composite_field-2.0.1.tar.gz.

File metadata

  • Download URL: django_composite_field-2.0.1.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-49-generic

File hashes

Hashes for django_composite_field-2.0.1.tar.gz
Algorithm Hash digest
SHA256 57be0caf9fbdeca5bf055339e276231273e4720911965f2fcdaf239fa6ffe152
MD5 22a8dfe35a089bae9507ce054b172171
BLAKE2b-256 ee02148add06846c2ab3c80e2f4181fb562b08bec026092f8e50a05b7593304a

See more details on using hashes here.

File details

Details for the file django_composite_field-2.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_composite_field-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 46decf22590b29dfd4dcc7810657f1dbf38a845702569c3ea68ef70d7373ce28
MD5 8d0ea50be796a2b560831faffe7b1fbf
BLAKE2b-256 59b346c9ec541f30f1a27e1519e2166612c8d909434c70f6fb0ed0bf044c64a5

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