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

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-expression-fields-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c23ab087d2d7b6ce4ac1cbceb5febfcdfaf756ca0e02dd502b2cb8088889fc14
MD5 4144865ac0ead5aa152508733d504e28
BLAKE2b-256 7ba621bda8d0f89d4b6ab7678843c0e265b2fd79b8c4e4f35d3aa601a1eccc1f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page