对于部署服务器安装很有用。添加管理命令以对项目进行配置。自动识别三方应用程序中的媒体目录
redsolutioncms.django-server-config的Python项目详细描述
安装:
在设置中。py:
将 配置 放到已安装的应用程序
为项目设置域名
CONFIG_SITES = ['www.project-name.com', ]
要重定向到站点的域
CONFIG_REDIRECTS = ['project-name.com', ]
提供静态文件
< Buff行情>为不寻常的三方应用程序设置媒体路径
CONFIG_APP_MEDIA = { 'application-name': [ ('media-root', 'media-url', ), ] }
将自动添加与应用程序module同名的媒体文件夹。 例如,在 tinymce 模块媒体文件中
tinymce/ media/ tinymce/ js/tinymce.js css/style.css
网址:
/media/tinymce/js/tinymce.js /media/tinymce/css/style.js
< > >
住手!django staticfiles不是这么做的吗?
是的,他们有。但是django servre config比staticfiles旧,并且做相同的工作。此功能将被弃用,并且自0.2.x版本起将不受支持。我们建议使用django contrib application django.contrib.statifiles 。请阅读下面的操作说明。
在url.py:
如果使用django服务器配置为静态媒体提供服务,请在调试模式下为静态文件提供服务的url.py中添加以下代码。在django.views.static.serve之前添加它
if settings.DEBUG: urlpatterns += patterns('', (r'^', include('config.urls')))
< > >
内置.cfg:
如果您使用的是zc.buildout,则可以将其添加到您的部件中,以使配置文件自动生成:
[make-config] recipe = iw.recipe.cmd on_install = true on_update = true cmds = sudo rm -f bin/init.d bin/lighttpd bin/logrotate bin/monit bin/*.py bin/django make_config init.d > bin/init.d bin/django make_config lighttpd > bin/lighttpd bin/django make_config logrotate > bin/logrotate bin/django make_config monit > bin/monit # Enable backups with duply & duplicity (http://duplicity.nongnu.org) bin/django make_config duply_conf > bin/duply_conf bin/django make_config duply_pre > bin/duply_pre bin/django make_config duply_post > bin/duply_post bin/django make_config duply_exclude > bin/duply_exclude # Collect static automaticaly sudo rm -Rf static bin/django collectstatic -l ---noinput sudo chown www-data:www-data -R static bin/django make_config install.py > bin/install.py bin/django make_config uninstall.py > bin/uninstall.py bin/django make_config enable.py > bin/enable.py bin/django make_config disable.py > bin/disable.py sudo chown root:root bin/* sudo chmod ug=rw,o=r bin/* sudo chmod ug=rwx,o=rx bin/init.d bin/django bin/buildout echo Configs were saved to "bin/"
< > >
无球虫
如果您不使用zc.buildlout,您可以使用上面的命令将其添加到存储库shell脚本中,它将产生相同的效果。