Django: import issue with python-twitter module

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

For example:

myproject/
    myapp/
        templatetags/
            file.py

      

In file.py

:

import twitter # this imports django.templatetags.twitter

      

Any idea to fix this?

Many thanks:)

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

+2


source to share


1 answer


Submodules often need to reference each other. For example, a surround module can use an echo module. In fact, such references are so common that the import statement looks first in the containing package before looking in the standard module search path. source

Hence, you will need to use absolute imports.



from some.other.pkg import twitter

      

+1


source







All Articles