tags:

views:

25

answers:

0

Technically not a django question, more a python question.

In urls.py I've got the following:

urlpatterns = patterns('locate.views',
    url(r'^',  'index.index'),
)

And a directory structure like this:

locate/
  views/
    __init__.py
    index.py      #  where there is "def index(request) : ...."

What I would like to do is avoid having to say "index.index", but rather have things flatten out a bit. Thus yielding:

urlpatterns = patterns('locate.views',
    url(r'^',  'index'),
)

This of course is quite possible if I make __ init __.py contain:

from .index import index
...

But after the 99th time of doing that it would be nice to have it automated. I've gotten close with some poking around with __ import __ and the like but wondering if anybody else has a working code fragment and/or a better way to handle this pattern in django.