没有项目描述
django-mav的Python项目详细描述
django的模型属性值的实现,不使用泛型关系。
安装
使用pip安装(即将使用github):
pip install django-mav
或者,您可以安装下载或克隆此repo并调用pip install -e .。
添加到您的settings.py:
'mav',
在模型中,用@mav装饰需要存储模型属性值的模型。
示例代码(foo/models.py)
from django.db import models
from mav.decorators import mav
@mav
class Foo(models.Model):
name = models.CharField(max_length=100)
# The @mav decorator will generate a FooAttr class in mav.attrs:
class FooAttr(AbstractModelAttribute):
# Inherited from AbstractModelAttribute
attribute = models.ForeignKey(Attribute)
value = models.TextField(...)
# Generated
object = models.ForeignKey(Foo, related_name='attrs')
文档
待办事项
要求
- python 2.6、2.7、3.2或3.3
- django>;=1.4
欢迎对其他django和python版本的贡献和pull请求。
许可证
你可以在麻省理工学院的许可下使用这个。有关详细信息,请参见LICENSE文件。