Metadata-Version: 1.1
Name: django-computedfields
Version: 0.0.2
Summary: autogenerated and autoupdated database fields for decorated model methods
Home-page: https://github.com/netzkolchose/django-computedfields
Author: netzkolchose
Author-email: j.breitbart@netzkolchose.de
License: MIT
Download-URL: https://github.com/netzkolchose/django-computedfields/archive/0.0.2.tar.gz
Description: |Build Status| |Coverage Status|
        
        django-computedfields
        ~~~~~~~~~~~~~~~~~~~~~
        
        django-computedfields provides autogenerated autoupdated database fields
        for model decorator functions.
        
        Tested with Django 2.11 with Python 2.7 and Python 3.4.
        
        Example
        ^^^^^^^
        
        Just derive your model from ``ComputedFieldsModel`` and place the
        ``@computed`` decorator at a method:
        
        .. code:: python
        
            from django.db import models
            from computedfields.models import ComputedFieldsModel, computed
        
        
            class MyModel(ComputedFieldsModel):
                name = models.CharField(max_length=32)
                
                @computed(models.CharField(max_length=32))
                def computed_field(self):
                    return self.name.upper()
        
        ``computed_field`` will be turned into a real database field and can be
        accessed and searched like any other database field. During saving the
        associated method gets called and it’s result written to the database.
        With the method ``compute('fieldname')`` you can inspect the value that
        will be written, which is useful if you have pending changes:
        
        .. code:: python
        
            >>> person = MyModel(forename='berty')
            >>> person.computed_field             # empty since not saved yet
            >>> person.compute('computed_field')  # outputs 'BERTY'
            >>> person.save()
            >>> person.computed_field             # outputs 'BERTY'
        
        The ``computed`` decorator supports a ``depends`` keyword argument to
        indicate dependencies to other model fields. If set, the computed field
        gets automatically updated upon changes of the related fields.
        
        Documentation
        ^^^^^^^^^^^^^
        
        See the documentation can be found
        `here <https://django-computedfields.readthedocs.io/en/latest/index.html>`__.
        
        TODO
        ^^^^
        
        -  support Django 2.x
        -  support one2one relations
        -  better reducing of m2m dependency updates
        -  cleanup messy dependency resolver map creation
        -  advanced test cases with mixed dependencies
        -  dependencies with Django’s F objects
        -  eval usage of stored procedures and complex annotations
        
        .. |Build Status| image:: https://travis-ci.org/netzkolchose/django-computedfields.svg?branch=master
           :target: https://travis-ci.org/netzkolchose/django-computedfields
        .. |Coverage Status| image:: https://coveralls.io/repos/github/netzkolchose/django-computedfields/badge.svg?branch=master
           :target: https://coveralls.io/github/netzkolchose/django-computedfields?branch=master
        
Keywords: django,method,decorator,autoupdate,persistent
Platform: UNKNOWN
