Alcott
Alcott

Reputation: 18625

urls.py in django

Here is the problem, the urls.py file in a django project look like this:

urlpatterns = patterns('',
    ...
    url(r'^admin/', include(admin.site.urls)),
    url(r'^testapp/', include('testapp.urls')),  #Here is the problem.
)

And I got an app installed, it is called 'testapp', so I wrote the include('testapp.urls') in the patterns.

The problem is that, Why should I put the testapp.urls in the quotation marks? Cuz I tried to put it like this: url('r^testapp/', include(testapp.urls)), it didn't work. Why?

Upvotes: 1

Views: 769

Answers (2)

joel goldstick
joel goldstick

Reputation: 4493

ad3w has answered your question. If you want to learn a little more about it check this out: http://www.djangobook.com/en/2.0/chapter08/

Upvotes: 1

ssbb
ssbb

Reputation: 2025

Your must import app in urls.py

import testapp

urlpatterns = patterns('',
    ...
    url(r'^admin/', include(admin.site.urls)),
    url(r'^testapp/', include(testapp.urls)),
)

Upvotes: 4

Related Questions