What is the regular expression for the "root" of a website in django?

I use django, and when users go to www.website.com/, I want to point them to an index.

Now I am doing this:

(r'^$', 'ideas.idea.views.index'),

However, it does not work. I assume my regex is wrong. Can someone help me? I looked at python regexes but they didn't help me.

+5
source share
3 answers

What you have should work (it is for me). Make sure it is at the top urls.pyand it should also be at the top of the list.

+4
source

Just enter an empty regex: r ''

, .

urlpatterns = patterns('',
    url(r'', include('homepage.urls')),
)

, !

EDIT:

:

urlpatterns = patterns('',
    url(r'\?', include('homepage.urls')),
)

.

+2

Is there a way that you can just use the general view and go straight to the template for your index page ?:

urlpatterns += patterns('django.views.generic.simple',
    (r'', 'direct_to_template', {'template': 'index.html'}),
)
0
source

All Articles