Site name appearing in django URLs
I'm having an issue where a call to the url template tag in Django is appending the site name (I don't want it in there.)
Let's say that the site name is 'mysite'.
So for example:
<a href="{% url myapp.views.myview "myparam" %}"&g开发者_高级运维t;Link text</a>
is producing:
<a href="/mysite/foo/bar">Link text</a>
when I want it to produce:
<a href="/foo/bar">Link text</a>
My urls.py is set up like this:
from django.conf.urls.defaults import *
import mysite.myapp.views
urlpatterns = patterns('',
(r'^/foo/bar/$', 'mysite.myapp.views.myview'),
)
Can anyone point me in the right direction?
Edit - when the site was in development, it was on a subdirectory of a test server, with the app as the subdirectory! So it was sitting on http://www.mytestserver.com/mysite. There's no caching in place, and all the references to /mysite were removed prior to going live.
Check your modpython configuration, if you've got one. There may be a line that looks like PythonOption django.root /mysite
Remove that.
Are you sure, that this is the rendered version? Docs say, that an absolute url should be produced, i.e. /mysite/foo/bar
. Are you checking source in the browser? Try printing out the result of render_to_string
(or other rendering function you are using) and check, if there example.com is added too.
精彩评论