Django 4.0 alpha 1 发布
(摘自开源中国)Django 4.0 发布了首个 alpha 版本,标志着已进入功能冻结阶段。开发团队称计划在未来一个月内发布 beta 测试版,然后在测试版发布一个月后推出 RC 候选版。
增加scrypt密码哈希器
新的scrypt密码哈希器比 PBKDF2 更安全,建议使用。但它不是默认选项,因为它需要 OpenSSL 1.1 以上版本和更多的内存。
Redis 缓存后端
django.core.cache.backends.redis.RedisCache缓存后端为使用 Redis 缓存提供了内置支持。此功能需要 redis-py 3.0.0 或更高版本。有关更多详细信息,请查看有关在 Django 中使用 Redis 进行缓存的文档。
基于模板的表单渲染
为了提高定制Forms、Formsets 和ErrorList,开发者现在正在使用的模板引擎进行渲染。
函数式的唯一约束
UniqueConstraint()的新*expressionspositional 参数可以在表达式和数据库函数上创建函数式唯一约束。例如:
from django.db import models
from django.db.models import UniqueConstraint
from django.db.models.functions import Lower
class MyModel(models.Model):
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
class Meta:
indexes = [
UniqueConstraint(
Lower('first_name'),
Lower('last_name').desc(),
name='first_last_name_unique',
),
]
推荐这些文章:
全自动:利用orm自动创建第三张关系表
缺点:扩展性差
1 class Book(models.Model):
2 name = models.CharField(max_length=32)
3 authors = models.ManyToManyField(to='Author')
4 class Author(models.Model):
5 name = models.CharField(max_length=32)
纯手动:
缺点:无法使用部分orm方法:add,set,remove,clear,正...
文章标题:Django 4.0 alpha 1 发布
文章链接:https://www.dianjilingqu.com/51132.html
本文章来源于网络,版权归原作者所有,如果本站文章侵犯了您的权益,请联系我们删除,联系邮箱:saisai#email.cn,感谢支持理解。
文章链接:https://www.dianjilingqu.com/51132.html
本文章来源于网络,版权归原作者所有,如果本站文章侵犯了您的权益,请联系我们删除,联系邮箱:saisai#email.cn,感谢支持理解。
THE END