1

All of my URLs in Django are coded relative to the root URL: /login/, /logout etc. I want to deploy the app to the sub url : www.example.com/app, and I want the URLs to be www.example.com/app/login/, www.example.com/app/logout. How do I do this efficiently?

1 Answer 1

1

You must modify your hard coded links to use Django's reversal methods. For example, instead of

<a href="/login/">Login</a>

you should use

<a href="{% url 'accounts_login' %}">Login</a>

this will allow Django to dynamically determine the URLs with respect to the root URL.

Sign up to request clarification or add additional context in comments.

2 Comments

Can you please provide more information? I defined url as url(r'^$', interface_page, name = 'index'), and call them from template but it's not working yet. My urls are: /login, /logout, /profile/, /profile/change, and /profile/delete.
You must use the name of your URLs, like {% url 'index' %} when constructing your links in the templates. See docs.djangoproject.com/en/1.7/topics/http/urls/… for details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.