Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brechin/django-computed-property
Computed Property Fields for Django
https://github.com/brechin/django-computed-property
computed-property django django-models fields
Last synced: 15 days ago
JSON representation
Computed Property Fields for Django
- Host: GitHub
- URL: https://github.com/brechin/django-computed-property
- Owner: brechin
- License: mit
- Created: 2018-01-27T03:13:10.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-28T13:58:31.000Z (over 5 years ago)
- Last Synced: 2024-08-15T19:16:21.077Z (3 months ago)
- Topics: computed-property, django, django-models, fields
- Language: Python
- Size: 30.3 KB
- Stars: 44
- Watchers: 2
- Forks: 6
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[![Coverage Status](https://coveralls.io/repos/github/brechin/django-computed-property/badge.svg?branch=master)](https://coveralls.io/github/brechin/django-computed-property?branch=master)
[![Build Status](https://travis-ci.org/brechin/django-computed-property.svg?branch=master)](https://travis-ci.org/brechin/django-computed-property)
# django-computed-property
Computed Property Fields for DjangoInspired by [Google Cloud Datastore NDB Computed Properties](https://cloud.google.com/appengine/docs/standard/python/ndb/entity-property-reference#computed).
Automatically store a computed value in the database when saving your model so you can filter
on values requiring complex (or simple!) calculations.## Quick start
1. Install this library
```
pip install django-computed-property
```
1. Add to `INSTALLED_APPS`
```python
INSTALLED_APPS = [
...,
'computed_property'
]
```1. Add a computed field to your model(s)
```python
from django.db import models
import computed_property
class MyModel(models.Model):
doubled = computed_property.ComputedIntegerField(compute_from='double_it')
base = models.IntegerField()
def double_it(self):
return self.base * 2
```Documentation available at http://django-computed-property.readthedocs.io/en/latest/