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

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第三方库


热门话题
javascript生成两点之间的固定纬度和经度   java为什么不删除并重命名文件?   求数组的和   java在漂亮面孔中使用正则表达式   SOAP(java)中的Hello World。如何修复它?   java I获取应用程序生成错误,配置为“”的资源“attr/arc_position”的值重复   云基础环境中的Java SFTP客户端应用   谷歌应用程序引擎Java查询日期不正常?   java使用cancel按钮对JOptionPane InputDialog循环进行转义   java数字格式总是返回异常   xquery Java Saxon API以“追加”模式写入文件   java Azure函数在第二个插槽中没有响应   java在构建Play应用程序后向其添加动态依赖项   json如何使用Jackson mapper for java。木卫一。可序列化类型字段?