未知

django-object-utils的Python项目详细描述


django对象实用程序

这个小库为更新django模型对象提供了帮助,而无需争用条件。

安装

pip install django-object-utils

用法

fromdjango_object_utilsimportreload_object,update_object,lock_objectuser=User.objects.get(pk=1)# Reload object in-place with the latest version from the databasereload_object(user)# Run SQL UPDATE for certain fields only and update the Python objectupdate_object(user,username='john',email='john@gmail.com')# Run SQL UPDATE and then reload the object from the databaseupdate_object(user,balance=F('balance')+payment,reload=True)ifrequest.method=='POST':withtransaction.atomic():# Enter a critical section and ensure that the object is the latest version.# Use the corresponding database row as the synchronization monitor.lock_object(user)form=UserForm(data=request.POST)form.save()

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

推荐PyPI第三方库


热门话题
jsp中的java显示图像(web商店)   如何在java中通过数组的键访问它,并将数组存储在hashmap中   实现给定接口的类的java AspectJ静态类型间声明   java HttpUrlConnection无法上载文件   爪哇:日期(第二天)   Java Selenium FirefoxDriver忽略给定的代理设置   Java JPA ORM映射   java如何制作Netbeans拥有的桌面窗格   java Eclipse:Eclipse启动器无法找到其配套的共享库   java如何检查数据库是否以只读模式运行?   java如何使用多个主类运行spring boot项目   java无法将Jconsole连接到Websphere SSL   java是否可以将数据时间选择器对话框限制为仅以小时半小时为单位显示时间?   java如何使用应用程序。javax中的属性值。验证注释   java如何修复集合的compareTo方法?   Java 7 NIO/JPathWatch在Windows中移动目录时出现问题   java项目反应器将两个发布服务器有状态地组合起来并发出结果   JavaSpring需要使用注释进行依赖注入