mirror of
https://github.com/jazzband/django-eav2.git
synced 2026-03-16 22:40:26 +00:00
* Add debug Q-expr print function * Change old __unicode__ methods to __str__ format * Move __unicode__ methods to __str__ * Rewrite AND Q-expressions to safe form * Make Q-expr debug print method use nicer format * Document rewrite_q_expr function * Rewrite/improve queries' test * Document some more code * Reorganize and document queryset module * Add more tests for queries * Use generic relation attribute instead instead of 'eav_values' * Update docstring * Fix a typo * Move up a variable * Rename a function * Check if 'in' filter rhs is not a QuerySet * Add newline to the end of file * Fix typo; tweak docstring
26 lines
693 B
Python
26 lines
693 B
Python
'''
|
|
Decorators module.
|
|
|
|
This module contains pure wrapper functions used as decorators.
|
|
Functions in this module should be simple and not involve complex logic.
|
|
'''
|
|
|
|
def register_eav(**kwargs):
|
|
'''
|
|
Registers the given model(s) classes and wrapped Model class with
|
|
django-eav::
|
|
|
|
@register_eav
|
|
class Author(models.Model):
|
|
pass
|
|
'''
|
|
from . import register
|
|
from django.db.models import Model
|
|
|
|
def _model_eav_wrapper(model_class):
|
|
if not issubclass(model_class, Model):
|
|
raise ValueError('Wrapped class must subclass Model.')
|
|
register(model_class, **kwargs)
|
|
return model_class
|
|
|
|
return _model_eav_wrapper
|