Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

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.

Files for django-expression-fields, version 0.3.0
Filename, size File type Python version Upload date Hashes
Filename, size django-expression-fields-0.3.0.tar.gz (4.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page