I'm trying to create a custom template tag. I've added a feedimport app in my project, added it on my installed apps, and inside it I've created a templatetag directory with a file feed_import.py
Both feedimport and templatetag dirs have an empty __init__.py file. I'm trying to load my feedimport with {% load feedimport %} in a template, but it says: TemplateSyntaxError: 'feed_import' is not a valid tag library: Could not load template library from django.templatetags.feed_import, No module named feedparser What's wrong? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is the source code of my feed_import.py file: import urllib, os, time, datetime, feedparser from django.conf import settings from django import template register = template.Library() @register.inclusion_tag('feedimport/pull_feed.html') def pull_feed(feed_url, posts_to_show=5, cache_expires=30): CACHE_FILE = ''.join([settings.CACHE_FOLDER, template.defaultfilters.slugify(feed_url), '.cache']) try: cache_age = os.stat(CACHE_FILE)[8] except: #if file doesn't exist, make sure it gets created cache_age = 0 #is cache expired? default 30 minutes (30*60) if (cache_age + cache_expires*60 < time.time()): try: #refresh cache urllib.urlretrieve(feed_url,CACHE_FILE) except IOError: #if downloading fails, proceed using cached file pass #load feed from cache feed = feedparser.parse(open(CACHE_FILE)) posts = [] for i in range(posts_to_show): pub_date = feed['entries'][i].updated_parsed published = datetime.date(pub_date[0], pub_date[1], pub_date[2] ) posts.append({ 'title': feed['entries'][i].title, 'summary': feed['entries'][i].summary, 'link': feed['entries'][i].link, 'date': published, }) return {'posts': posts} -- Alessandro Ronchi Skype: aronchi http://www.alessandroronchi.net - Il mio sito personale http://www.soasi.com - Sviluppo Software e Sistemi Open Source --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---