Django的URL标签添加文件路径 [英] Django url tag adds filepath
问题描述
在urls.py中,我定义为
In urls.py, I defined as,
url(r'^'+ settings.URL_PREFIX + r'$','myapp.project.views.index',name ="homepage"),
url(r'^'+settings.URL_PREFIX+r'$', 'myapp.project.views.index', name="homepage"),
在settings.py中,我将URL_PREFIX定义为
in settings.py, I defined URL_PREFIX as,
URL_PREFIX ='myapp/'
URL_PREFIX = 'myapp/'
在模板中,我在锚点中使用url标签,
and in template, I used url tag in an anchor as,
{%url主页%}
{% url homepage %}
链接变为:
http://localhost/home/muluturk/web/myapp/myapp/,而不是 http://localhost/myapp/.它添加了/home/muluturk/web/myapp/,这是项目的目录.我该如何解决?
http://localhost/home/muluturk/web/myapp/myapp/ instead of http://localhost/myapp/. It adds /home/muluturk/web/myapp/ whis is the directory of project. How can I fix this?
推荐答案
问题已解决.是由apache配置文件引起的:
Problem solved. It caused by apache config file:
PythonOption django.root/home/muluturk/web/myapp
PythonOption django.root /home/muluturk/web/myapp
从此行中删除/home/muluturk/web/myapp解决了我的问题
Removing /home/muluturk/web/myapp from this line solved my problem
这篇关于Django的URL标签添加文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!