python - Error importing external library within Django template tag library -
So I'm trying to write a Django reusable app to display your Twitter feed on your page Provides a method. I know well that this 20 times already exists. It is an academic exercise :)
The directory structure is very simple:
myproject | __ __init__.py | __ manage.py | __ settings.py | __ myapp | __ __init__.py | ___ admin.py | __ conf | __ __init__.py | __ appsettings.py | __ feedparser.py | __Model_You | __Templates | __ __init__.py | __ templatetags | __ __init__.py | __ twitterfeed.py | __ViewJava | __Templates | __ base.html | ___ urls.py
On running the newgen shell, the functions defined in twitterfeed.py work perfectly. I also believe that I have a template tag properly enrolled and registered.
As you can see, I use the excellent my problem is not just within the UFP, but the template tag library is said to be in the inability of UFP while importing. When I get the {% load twitterfeed%}
in base.py, I get the following error:
'twitterfeed' is not a valid tag library: load the template Can not be used from Django.templatetags.twitterfeed library, a module called feedparser
I import feedparser using the following statement:
Import From time to time, myapp Feedparser
The best I can tell, this error message is a little cheated. I think that when a template library is full, and when this template library is full, then it is an imported irrawl.
Can I import feedparser.py in my reusable app without any other way to the users of the place, place the FeedParser somewhere in their Pathhenpath?
Thank you!
It looks similar to those disturbing relative path problems - Python 2.6 and higher (where you can import Are .. circles etc), but on older versions it is often a little difficult. A cheaper and delightful way to fix this just to move feedparser.py to your templatetag directory, twitterfeed.py
Comments
Post a Comment