[英]Unable to use admin's static file when debug is False in django
I browsed these question but not found correct answer. 我浏览了这些问题,但没有找到正确的答案。 Here is my problem..
这是我的问题。
I have some static files.Here is the dir.. 我有一些静态文件。这是目录。
/home/user/djangoproject/djangoapp/static / home / user中/ djangoproject / djangoapp /静
/home/user/djangoproject/templates/base.html (where I have modify some for django admin page) /home/user/djangoproject/templates/base.html(我在其中修改了django管理页面的内容)
After setting debug = False, I have change setting.py like this 设置debug = False后,我像这样更改了setting.py
DEBUG = False
ALLOWED_HOSTS = ['*',]
STATIC_URL = '/static/'
STATIC_ROOT = "/home/user/djangoproject/djangoapp/static/"
and my urls.py is 而我的urls.py是
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^$',login),# and some more views
)+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
After that I have collect all admin static to my app's custom static dir path like this.. 之后,我将所有管理静态信息收集到应用程序的自定义静态目录路径中,如下所示。
/home/user/djangoproject/djangoapp/static/admin/css & all others / home / user / djangoproject / djangoapp / static / admin / css和所有其他
Now my problem is that when I am using my custom static file, It's working but for example admin login page & admin site, admin static file is not working..So where am I doing wrong, or what extra I have to do. 现在我的问题是,当我使用自定义静态文件时,它可以工作,但是例如,管理员登录页面和管理站点,管理静态文件不起作用。那么,我在哪里做错了,或者我必须做些什么。
Thanks in advance... 提前致谢...
You need to set up a web server to serve the static files. 您需要设置一个Web服务器来提供静态文件。 If you are using Apache, adding something along the lines of
如果您使用的是Apache,请添加以下内容:
Alias /static/ /home/user/djangoproject/djangoapp/static/
<Directory /home/user/djangoproject/djangoapp/static>
Order deny,allow
Allow from all
</Directory>
to httpd.conf should do the trick. 到httpd.conf应该可以解决问题。 For more info see https://docs.djangoproject.com/en/1.6/howto/static-files/deployment/
有关更多信息,请参见https://docs.djangoproject.com/en/1.6/howto/static-files/deployment/
To serve also the Django project through Apache, add 要同时通过Apache服务Django项目,请添加
WSGIScriptAlias / /home/user/djangoproject/djangoproject/wsgi.py
WSGIPythonPath /home/user/djangoproject
<Directory /home/user/djangoproject/djangoproject>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
Alias /static/ /home/user/djangoproject/djangoapp/static/
<Directory /home/user/djangoproject/djangoapp/static>
Order deny,allow
Allow from all
</Directory>
to httpd.conf. 到httpd.conf。 For instructions about how to set up Django with Apache, see https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi/
有关如何使用Apache设置Django的说明,请参见https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.