James Franco
James Franco

Reputation: 4716

Django map root to another url

Being new to Django app development I finally finished my app. Now I would like the home page to load as the root. Suppose my website is www.foo.com Currently I do something like this

http://foo.com/home

to bring up the front page. I would like to bring the front page up without typing /home. I tried doing this to my urls.py by adding the first entry however that does not seem to work. Any suggestions ?

    urlpatterns = [
        url(r'^/$'    ,'main.views.promptLogin' , name="home"), #First page to show at index
        url(r'home$'    ,'main.views.promptLogin' , name="home"), #First page to show at index
]

Upvotes: 0

Views: 86

Answers (1)

W.K.S
W.K.S

Reputation: 10095

This:

url(r'^/$'    ,'main.views.promptLogin' , name="home")

corresponds to http://foo.com// because Django adds a / to the end of foo.com by default.

What you probably want is:

url(r'^$'    ,'main.views.promptLogin' , name="home")

which corresponds to

http://foo.com/

Upvotes: 1

Related Questions