Django的自动弹头场。
django-autoslug的Python项目详细描述
Django autoslug是一个可重用的Django库,它提供了一个改进的 弹头场可自动:
- 从另一个字段填充自身,
- 保持值的唯一性并
- 使用自定义的slugify()函数获得更好的i18n。
该字段是高度可配置的
要求
python 2.7、3.5+或pypy。
django 1.7.10或更高。
在其他环境中成功使用Django Autoslug是可能的 但它们没有经过测试。
注意
PyPy3不受官方支持,只是因为 与django autoslug本身无关的ci上的权限和__pycache__。
示例
一个简单的例子:
fromdjango.db.modelsimportCharField,ModelfromautoslugimportAutoSlugFieldclassArticle(Model):title=CharField(max_length=200)slug=AutoSlugField(populate_from='title')
更复杂的例子:
fromdjango.db.modelsimportCharField,DateField,ForeignKey,Modelfromdjango.contrib.auth.modelsimportUserfromautoslugimportAutoSlugFieldclassArticle(Model):title=CharField(max_length=200)pub_date=DateField(auto_now_add=True)author=ForeignKey(User)slug=AutoSlugField(populate_from=lambdainstance:instance.title,unique_with=['author__name','pub_date__month'],slugify=lambdavalue:value.replace(' ','-'))
文件
见complete documentation 准备好了。它是为最新版本自动生成的。
社区
此应用程序由justin mayer维护。它最初是由 然后由其他开发人员改进。它们列在 作者.rst。
请随时提交问题和/或提交修补程序
有关首选工作流的提示,请参见contribution.rst。
许可
django autoslug是免费软件;您可以重新分发它和/或 根据GNU Lesser通用公共许可证的条款修改为 由自由软件基金会出版;或 许可证,或(由您选择)任何更高版本。
Django Autoslug的发行是希望它能有用, 但没有任何保证;甚至没有 适销性或适合某一特定目的的适销性。看GNU 更详细的信息,请参阅较低的通用公共许可证。
你应该收到一份GNU的副本 与此程序一起使用许可证;请参阅文件copying.lesser。如果不是, 见GNU licenses。