用于处理生日的助手字段和管理器

django-birthda的Python项目详细描述


Django Birthday是一个帮助库,用于处理模型中的生日。

作者是Jonas Obrist,一些伟大的 contributors

https://img.shields.io/pypi/v/django-birthday.svghttps://img.shields.io/pypi/dm/django-birthday.svghttps://img.shields.io/github/license/bashu/django-birthday.svghttps://img.shields.io/travis/bashu/django-birthday.svg

安装

pip install django-birthday

用法

django birthday提供了一个birthday.fields.BirthdayField模型 字段类型,它是django.db.models.DateField和 因此也有同样的特点。它还在内部添加了 第二个领域,你的模型举行了一年中的一天 生日,这用于 birthday.managers.BirthdayManager应该用作 你的模特经理。

模型可能是这样的:

fromdjango.dbimportmodelsimportbirthdayclassUserProfile(models.Model):user=models.ForeignKey('auth.User')birthday=birthday.fields.BirthdayField()objects=birthday.managers.BirthdayManager()

在未来30天内获取所有用户配置文件:

UserProfile.objects.get_upcoming_birthdays()

获取所有今天生日的用户配置文件:

UserProfile.objects.get_birthdays()

或根据用户的生日订购用户配置文件:

UserProfile.objects.order_by_birthday()

有关更多详细信息,请参阅阅读文档中的documentation

许可证

django-birthday是根据bsd许可证发布的。

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

推荐PyPI第三方库


热门话题
如何为我的jsp/java web项目实现使用twitter登录   java KeyListener是否停止使用动作或鼠标Listener?   java Android:RecyclerView表现为GridLayout   java Appassembler在生成的脚本中构建错误的类路径   Java 11 JLink获取错误:自动模块不能与JLink:com一起使用。微软sqlserver。来自文件的jdbc   java如何检查Android tabview中打开的选项卡   java非固定大小Fenwick树实现   java如何使用java8的completableFuture实现forEach列表循环   java如何在Eclipse中指定测试类路径   java我们可以中断一个已经获得锁的线程吗?   java使用JSONPATH规范化嵌套json   在java中创建异常列表