views:

262

answers:

1

Hi,

When I try to import python-twitter module in my app, django tries to import django.templatetags.twitter instead of python-twitter module (in /usr/lib/python2.5/site-packages/twitter.py), but I don't know why. :s

For example:

myproject/
    myapp/
        templatetags/
            file.py

In file.py:

import twitter # this imports django.templatetags.twitter

Any idea to fix it ?

Thank you very much :)

Edit: I've found the problem. My templatetags file was named "twitter.py". I've renamed it to "twitter_tags.py" and now this works. :)

+2  A: 

The submodules often need to refer to each other. For example, the surround module might use the echo module. In fact, such references are so common that the import statement first looks in the containing package before looking in the standard module search path. source

Therefore, you will need to use an absolute import.

from some.other.pkg import twitter
geowa4