lud0h
lud0h

Reputation: 2390

URLconfs in Django

I am going through the Django sample application and come across the URLConf.

I thought the import statement on the top resolves the url location, but for 'mysite.polls.urls' I couldn't remove the quotes by including in the import statement.

Why should I use quotes for 'mysite.polls.urls' and not for admin url? and what should I do if I have to remove the quotes.

   from django.conf.urls.defaults import *
    ...
    ...
    (r'^polls/', include('mysite.polls.urls')),
    (r'^admin/', include(admin.site.urls)),

Upvotes: 0

Views: 322

Answers (1)

ars
ars

Reputation: 123498

You've elided a bunch of stuff, but do you have the following statement in there?

from django.contrib import admin

If so, that would explain why you don't need to quote the latter. See the django documentation for AdminSite.urls for more information.

If you want to remove the quotes from the former, then:

import mysite.poll.urls
...
(r'^polls/', include(mysite.poll.urls)),
...

should work.

Upvotes: 1

Related Questions