允许在管理中创建条件逻辑的django应用程序。
django-conditions的Python项目详细描述
#django条件
[![构建状态](https://travis-ci.org/revolvetech/django-conditions.svg?branch=master)(https://travis ci.org/revolvetech/django条件)
[![codecov](https://codecov.io/gh/revolvetech/django conditions/branch/master/graph/badge.svg)(https://codecov.io/gh/revolvetech/django conditions)
[![Codacy徽章](https://api.codacy.com/project/badge/grade/8fccc57f17e44c5496a912adc691fc39)(https://www.codacy.com/app/revolutiontech/django conditions)
[![依赖关系状态](https://www.versioneye.com/user/projects/56de7e4cdf573d0048dafc52/badge.svg?style=flat)(https://www.versioneye.com/user/projects/56de7e4cdf573d0048dafc52)
[![文档状态](https://readthedocs.org/projects/django-conditions/badge/?version=latest)(http://django conditions.readthedocs.org/en/latest/)
将经常从代码更改的条件逻辑移到模型中,以便在管理中轻松修改逻辑。一些可能的用例:
-将你的用户群划分成具有目标消息的队列
-根据用户的期望值为用户提供不同的奖励
-在游戏中,定义任务/任务的获胜目标
-以及更多…
<<
pip install django安装条件
>首先在代码中定义一个条件:
``python
` ``python
/>class-全名(条件)类(条件):
<
;姓名它出现在数据库中,表示条件
condstr='全名'
**kwargs):
返回bool(user.first_name和user.last_name)
````
>然后向模型添加一个条件字段:
``python
``models.py
from django.db import models
from conditions import conditions字段,conditions_from_module
import condition_type
class campaign(models.model):
text=models.textfield()
=conditionsfield(definitions=condition s-from-u-module(condition-types))
```
您可以输入json来表示您希望满足条件的时间。
``javascript
{
“all”:[“full_name”]
}
```
>现在您可以使用在管理中创建的逻辑来确定事件的结果:
``python
views.py
来自django.http import httpresponse
from conditions importeval_conditions
来自模型导入活动
def profile(请求):
用于活动中的活动。objects.all():
如果eval_conditions(活动,“目标”,request.user):
返回httprepose(campaign.text)
return httpresponse(“没什么新发现。”)
````
在django项目中使用django条件更改简单逻辑,而无需重新部署,把权力交给产品经理和其他非工程师。
您可以关注我的进度[在trello上](https://trello.com/b/xqnzhwyz)。
[在阅读文档时]提供完整的文档(http://django conditions.read the docs.org/)。
[![构建状态](https://travis-ci.org/revolvetech/django-conditions.svg?branch=master)(https://travis ci.org/revolvetech/django条件)
[![codecov](https://codecov.io/gh/revolvetech/django conditions/branch/master/graph/badge.svg)(https://codecov.io/gh/revolvetech/django conditions)
[![Codacy徽章](https://api.codacy.com/project/badge/grade/8fccc57f17e44c5496a912adc691fc39)(https://www.codacy.com/app/revolutiontech/django conditions)
[![依赖关系状态](https://www.versioneye.com/user/projects/56de7e4cdf573d0048dafc52/badge.svg?style=flat)(https://www.versioneye.com/user/projects/56de7e4cdf573d0048dafc52)
[![文档状态](https://readthedocs.org/projects/django-conditions/badge/?version=latest)(http://django conditions.readthedocs.org/en/latest/)
将经常从代码更改的条件逻辑移到模型中,以便在管理中轻松修改逻辑。一些可能的用例:
-将你的用户群划分成具有目标消息的队列
-根据用户的期望值为用户提供不同的奖励
-在游戏中,定义任务/任务的获胜目标
-以及更多…
<<
pip install django安装条件
>首先在代码中定义一个条件:
``python
` ``python
/>class-全名(条件)类(条件):
<
;姓名它出现在数据库中,表示条件
condstr='全名'
**kwargs):
返回bool(user.first_name和user.last_name)
````
>然后向模型添加一个条件字段:
``python
``models.py
from django.db import models
from conditions import conditions字段,conditions_from_module
import condition_type
class campaign(models.model):
text=models.textfield()
=conditionsfield(definitions=condition s-from-u-module(condition-types))
```
您可以输入json来表示您希望满足条件的时间。
``javascript
{
“all”:[“full_name”]
}
```
>现在您可以使用在管理中创建的逻辑来确定事件的结果:
``python
views.py
来自django.http import httpresponse
from conditions importeval_conditions
来自模型导入活动
def profile(请求):
用于活动中的活动。objects.all():
如果eval_conditions(活动,“目标”,request.user):
返回httprepose(campaign.text)
return httpresponse(“没什么新发现。”)
````
在django项目中使用django条件更改简单逻辑,而无需重新部署,把权力交给产品经理和其他非工程师。
您可以关注我的进度[在trello上](https://trello.com/b/xqnzhwyz)。
[在阅读文档时]提供完整的文档(http://django conditions.read the docs.org/)。