[英]django url template tag relative urls
So basically I've deployed my applicaiton on vps with apache and mod wsgi. 因此,基本上,我已将应用程序部署在具有Apache和Mod wsgi的vps上。 For my static files I've used {% url %} template tag like this : 对于我的静态文件,我使用了{%url%}模板标签,如下所示:
<link href="{% static "bootstrap.min.css" %}" rel="stylesheet">
Django wasn't loading static files because it was creating relative url so I fixed it by Django没有加载静态文件,因为它正在创建相对URL,因此我通过
<link href="/{% static "bootstrap.min.css" %}" rel="stylesheet">
But now when I go to /admin pages it's not loading static files, again because of the relative urls. 但是现在,当我进入/ admin页面时,由于相对URL的缘故,它并没有加载静态文件。 How can I fix this ? 我怎样才能解决这个问题 ?
Here's my mod wsgi : 这是我的mod wsgi:
import os
import sys
import site
# Add the app's directory to the PYTHONPATH
sys.path.append('/home/tshirtnation')
sys.path.append('/home/tshirtnation/tshirtnation')
os.environ['DJANGO_SETTINGS_MODULE'] = 'tshirtnation.settings'
os.environ['PYTHON_EGG_CACHE'] = '/tmp'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
And my apache configuration : 和我的Apache配置:
#Listen 80
<VirtualHost *:80>
ServerAdmin marijus.merkevicius@gmail.com
ServerName 5.199.166.109
WSGIDaemonProcess ts threads=25
WSGIProcessGroup ts
Alias /static /home/tshirtnation/staticfiles
WSGIScriptAlias / /home/tshirtnation/index.wsgi
</VirtualHost>
Let me know if you need anything else. 需要帮助请叫我。
I also had a problem with Django's admin static files. Django的管理静态文件也有问题。 That's what I used. 那就是我用的 Maybe it can be helpful. 也许会有所帮助。
This is for Nginx: 这是针对Nginx的:
location /static/admin {
alias "/pythonenv_path/lib/python3.2/site-packages/django/contrib/admin/static/admin";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.