具有django的flow-in-choices值的简单库

django_choices_flow的Python项目详细描述


具有简单流程和规则的元选择

Build StatusCoverage Status

用法

fromdjango.dbimportmodelsfromdjango_choices_flowimportChoicesfromdjango_choices_flow.modelsimportFlowIntegerFieldclassMyChoices(Choices):NEW=1,'New content'# 'New content' is the display textWAIT=2,'Wait'CANCELED=-1,'Canceled'ERROR=-2,'Error'INVOICED=3,'Invoiced'# set transaction rulesNEW_RULES=[NEW,INVOICED,CANCELED,ERROR]WAIT_RULES=[CANCELED,ERROR,INVOICED]INVOICED_RULES=[CANCELED]classInvoces(models.Model):"""
    To use only choices
    """number=models.IntegerField()status=models.IntegerField(choices=MyChoices,default=MyChoices.NEW)def__unicode__(self):returnself.numberclassFlowInvoice(models.Model):"""
    To validate flow in choices
    """number=models.IntegerField()status=FlowIntegerField(choices=MyChoices,default=MyChoices.NEW)def__unicode__(self):returnself.number

外壳

>>>flow=FlowInvoice.objects.create(number=1234)>>>flow.status1>>>flow.status=MyChoices.INVOICED>>>flow.full_clean()>>>flow.save()>>>flow.status3>>>flow.status=MyChoices.WAIT>>>flow.full_clean()ValidationError:{'status':[u'Invalid choice: Wait']}

显影剂

# download code
git clone git@github.com:valdergallo/django-choices-flow.git

# install developer packages
make

# check coverage
make coverage

# test project
make test#clean extra content
make clean

#send package
make send_package

#test py2 and py3
tox

License type: FREEBSD
South: Support migrations
Python: python 2.7 and python 3.3
Version: 0.9.2
Tested in Django: 1.2.x; 1.3.x; 1.4.x; 1.5.x; 1.6.x; 1.7.x

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Android中Axis2 web服务的java解析响应   java读取Dockerfile命令时遇到问题:是否可以将cd刻录到jar文件中?那么tarcf是做什么的呢?   java如何防止gcmTaskService periodicTask在上一个任务尚未完成时再次运行?   jquery希望使用Java生成自动登录程序   在Hibernate中检索用BigInteger映射的属性时出现java问题   与错误用户连接时发生java错误   java Hibernate+c3p0池+ehcache失败启动   JAVAlang.ClassNotFoundException:org。mysql。JDBC无法解决,添加了mysql连接器   java如何在其键包含JSTL中的点时访问映射值?   packageprivate类中的Java方法可访问性?   java如何将文件转换为StorageObject(谷歌API)   java apache commons httpclient 4.23表单登录问题不同请求中使用的不同会话cookie   所有组件的java一个侦听器instance或每个组件的一个实例   重新启动应用程序后,不会保存ListView中的java更新   java如何修复libgdx中的屏幕无渲染   java在使用mongotemplate时遇到ClassNotFound异常