tags:

views:

113

answers:

1

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)),
+1  A: 

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.

ars
Thx. Worky perfectly. Could you explain how quoting works? He tries to built from the current workpath?
lud0h
I haven't looked at the django source, but yes, I think it just tries to import some segment of the string, assuming it's on the PYTHONPATH. See the imp module for one possible way to make it work: http://docs.python.org/library/imp.html
ars