On 2/26/06, gabor <[EMAIL PROTECTED]> wrote: > the urlconf for the polls app is: > > urlpatterns = patterns('myproject.polls.views', > (r'^$', 'index'), > (r'^(?P<poll_id>\d+)/$', 'detail'), > (r'^(?P<poll_id>\d+)/results/$', 'results'), > (r'^(?P<poll_id>\d+)/vote/$', 'vote'), > ) > > it is nice that the "URL" handling is decupled, so we only deal with > the part of the URL that is important for us. > > but we still have to specify the whole name for the module > "myproject.polls.views". so if later i want to use this application in a > different project, i will have to change the urlconf in the application. > wouldn't it be better if i could simply say "polls.views.detail", or > "views.detail" ?
I'm thinking about changing the tutorial to use relative imports, so that the path won't be hard-coded. It would be something like this (not tested): urlpatterns = patterns(__name__ + '.views', (r'^$', 'index'), (r'^(?P<poll_id>\d+)/$', 'detail'), (r'^(?P<poll_id>\d+)/results/$', 'results'), (r'^(?P<poll_id>\d+)/vote/$', 'vote'), ) Yes, I realize __name__ + '.views' will result in something like 'myproject.polls.urls.views' -- some extra string mangling would have to be done. Adrian -- Adrian Holovaty holovaty.com | djangoproject.com | chicagocrime.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers -~----------~----~----~----~------~----~------~--~---