On 2/15/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I'm learning django these days. and urls.py is as follow: > ... > (r'^hello/$', 'web.hello.index'), > (r'^test/$', 'web.test.index'), > ... > > it looks complicated, can it be much simpler, even only one line? And > it can do the follow things?: > e.g. a) when access http://localhost/test, I means to call TEST's > index; > b) when access http://localhost/test/hello, I means to call TEST's > hello.
Hey there, The callbacks ('web.hello.index' and 'web.test.index', in your example) can be any callable Python object, so you could create some sort of special callable object that does that. Here's a sample callable class: class Foo: def __call__(self, request, *args, **kwargs): return HttpResponse("Hello world.") foo_instance = Foo() If the above code lives in path/to/bar.py, you'd put "path.to.bar.foo_instance" in your URLconf. Adrian -- Adrian Holovaty holovaty.com | djangoproject.com | chicagocrime.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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-users -~----------~----~----~----~------~----~------~--~---