Thursday, December 27, 2018

template {% url %} tag is giving server's absolute path

I have recently changed my django project (using A2 hosting) from fcgi to wsgi.  I have successfully gotten the project to work, but I am experiencing a minor caveat I am trying to solve.  Now, when I use the {% url %} tag in the templates to form a link, I get the absolute path of the server (the results still works but the link now looks more ugly).

For example, I might have this in my urls.py

url("^about_us/$", views.about_us, name="about_us")


Then in my template, I would have this

{% url "about_us" %}


In my development, the template will render the link "/about_us" so that when you click the link, it takes you to www.mysite.com/about_us.html

Now, in production, the template will render the link "/home/myproject/myproject/about_us" so that when you click the link, it takes you to www.mysite.com/home/myproject/myproject/about_us.html

How can I get my production template rendering of the url tag to replicate the development rendering of the url tag.

Thanks for any help!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cbdad29b-7048-48ac-82e8-f807bcd3bf22%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment