[Django]-Django installing multiple apps on the same page

3👍

Django works by matching a URL pattern to some code that you have written in views.py.

In your case, you are pointing the same pattern (^$) to two view methods. Django will stop when it finds a match, so when you switch the patterns around, it will always match the first entry in the list.

If you change your patterns to:

urlpatterns = patterns('',
        url(r'^/two$', 'myapp2.views.home2', name='home2'),
        url(r'^$', 'myapp1.views.home1', name='home1'),

Now when you type http://localhost:8000/two home2 will be executed, and when you type http://localhost:8000/ home1 will be executed.

Leave a comment