对于部署服务器安装很有用。添加管理命令以对项目进行配置。自动识别三方应用程序中的媒体目录

redsolutioncms.django-server-config的Python项目详细描述


安装:

在设置中。py:

  1. 配置 放到已安装的应用程序

  2. 为项目设置域名

    CONFIG_SITES = ['www.project-name.com', ]
    
  3. 要重定向到站点的域

    CONFIG_REDIRECTS = ['project-name.com', ]
    
  4. 提供静态文件

    < 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
    
  5. < > >

    住手!django staticfiles不是这么做的吗?

    是的,他们有。但是django servre config比staticfiles旧,并且做相同的工作。此功能将被弃用,并且自0.2.x版本起将不受支持。我们建议使用django contrib application django.contrib.statifiles 。请阅读下面的操作说明。

在url.py:

  1. 如果使用django服务器配置为静态媒体提供服务,请在调试模式下为静态文件提供服务的url.py中添加以下代码。在django.views.static.serve之前添加它

    if settings.DEBUG:
        urlpatterns += patterns('', (r'^', include('config.urls')))
    
  2. < > >

内置.cfg:

  1. 如果您使用的是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/"
    
  2. < > >

    无球虫

    如果您不使用zc.buildlout,您可以使用上面的命令将其添加到存储库shell脚本中,它将产生相同的效果。

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

推荐PyPI第三方库


热门话题
Android Studio中的Java错误,但不是Eclipse   java如何使用jsp更新数据库中的文件?   jsoup如何在java中从较大的子字符串中提取多个子字符串?   java RestFB:当页面的URI具有页面名称时,无法获取页面帖子   java可以让Maven做我们在ANT构建中正在做的事情。xml   java如何在JasperReports中动态包含来自Servlet的图像?   java在hibernate中用新集更新旧集   从导出为可运行的Java应用程序创建、解析和管理XML文件。jar文件   在Java中使用数组的基础知识   调试从JAVA程序调用的MATLAB函数   java实现了Iterable hands错误大小的备份   JAVA木卫一。FileNotFoundException:请求的资源不可用   java Android Spring 1.0.1使用基本身份验证删除   java如何使用com解析和对象在一个数字数组中的值。fasterxml。杰克逊。数据绑定。对象映射器   比较两个字符串时发生java NullPointerException