Skip to main content

django-expression-fields allows typing mathematical expressions into form fields and having only the calculated result stored in the database.

Project description

django-expression-fields lets your users type a mathematical expression in a form field. Python does the math and stores the result in the database. For example, suppose you have a model to track Things, like this:

class Thing(models.Model):
    cost = models.DecimalField(
            max_digits=5, decimal_places=2, null=True, blank=True)

Suppose Things come in packs of 12 for $7.99. Your users have to do some math to fill in the cost of a single Thing, $0.67.

But not with an expression field! Create your form like this:

class ThingForm(forms.Form):
        cost = DecimalExpressionField(
                max_digits=5, decimal_places=2, required=False)

Now your user can simply type 7.99/12 in the field and Python will do the math for them!

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-expression-fields-0.4.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django-expression-fields-0.4.0.tar.gz.

File metadata

  • Download URL: django-expression-fields-0.4.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for django-expression-fields-0.4.0.tar.gz
Algorithm Hash digest
SHA256 63d16c88046a2dd772c21f6cb4789ab941861a69511865ef0ccd33d5e640dea4
MD5 2dae8385e92eb3790974e381090c5428
BLAKE2b-256 eac5bc10cdedbbc5ae1c7449d1ad3d19e7076a9922795716aaa812f77cdaa4b4

See more details on using hashes here.

File details

Details for the file django_expression_fields-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: django_expression_fields-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for django_expression_fields-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be0f2b8c83435266dc15b52e52819a7ef1073a8ff8b749ff3433bd2b842c4ddd
MD5 d51c705cdee9c6f8674d79f57a5da4c8
BLAKE2b-256 850dd470c45c5acf063d0dede32ab84160404e4f406a3a8dc4aeb5048caad96b

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