财富的标记
django-fortune的Python项目详细描述
Django财富
提供财富的django模板标记。
模板标签
{% load fortune_tags %} {% fortune %}
管理命令
$ python manage.py fortune # Get a fortune. Fortunes will improve after loading some. # Oops, no fortunes loaded. $ python manage.py fortune_list_packs # List available fortune packs. -- Installed: -- -- Available: -- art ascii-art computers cookie definitions . . $ python manage.py fortune_load_pack art # Load art fortunes. $ python manage.py fortune # Get an art fortune. "My life is a soap opera, but who has the rights?" -- Madame $ python manage.py fortune_unload_pack art # Unload art fortunes. $ python manage.py fortune # No fortunes available again. :-( Fortunes will improve after loading some. $
python接口
$pythonmanage.pyshell..>>>fromfortune.modelsimportFortune,Pack>>>Fortune.fortune()'Fortunes will improve after loading some.'>>>fromfortuneimportutils>>>fortunes_path=utils.get_fortunes_path()>>>art_fortunes_path=fortunes.path.joinpath("art")>>>Pack.load(str(art_fortunes_path))>>>Fortune.fortune()u"\nThey can't stop us... we're on a mission from God!\n\t\t-- The Blues Brother">>>art_fortunes=Pack.objects.get(name="art".title())>>>art_fortunes.unload()>>>Fortune.fortune()'Fortunes will improve after loading some.'>>>
安装
使用pip;安装
$ pip install django-fortune
然后将“fortune”添加到应用程序settings.py中已安装的应用程序中。