#6538 closed (invalid)
"Complex" Syndication Example Error?
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | contrib.syndication | Version: | dev |
| Severity: | Keywords: | rss, syndication | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Following the example at: http://www.djangoproject.com/documentation/syndication_feeds/#a-complex-example
I've arrived at the following:
class BpostCatPosts(Feed):
"""
Shows the latest blog posts from an individual blog post category.
"""
def get_object(self, bits):
# In case of "/feeds/bpcatposts/0613/foo/bar/baz/", or other such clutter,
# check that bits has only one member.
if len(bits) != 1:
raise ObjectDoesNotExist
return BlogCategory.objects.get(id__exact=2)
def title(self, obj):
return "Greg Taylor's Latest: %s" % obj.name
def link(self, obj):
if not obj:
raise FeedDoesNotExist
return obj.get_absolute_url()
def description(self, obj):
return "The latest posts from the %s category of Greg Taylor's blog." % obj.name
def items(self, obj):
return BlogPost.objects.filter(category=[obj.id])[:10]
My feed section of urls.py looks like this:
feeds = {
'latest_bpost': LatestBposts,
'latest_bpostcat': BpostCatPosts,
}
urlpatterns = patterns('',
# Serve Media via Django
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
# Default Page
(r'^', include('apps.pages.urls')),
# Standard Pages
(r'^pages/', include('apps.pages.urls')),
# Blog URLs
(r'^blog/', include('apps.blog.urls')),
# Django Admin Interface
(r'^admin/', include('django.contrib.admin.urls')),
# RSS Feeds
(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
)
When visiting the URL http://localhost:8000/feeds/latest_bpostcat/2/ I am getting the following error:
InterfaceError at /feeds/latest_bpostcat/2/ Error binding parameter 0 - probably unsupported type.
I've looked over this quite a few times and can't figure out if the API has changed or if there was an omission. I've tried my best to assure that the error wasn't on my part.
Change History (3)
comment:1 by , 18 years ago
comment:2 by , 18 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
This is an error in your code. Run this line
BlogPost.objects.filter(category=[obj.id])[:10]
in the Django shell and you'll see the same error. You probably want to use the __in lookup type there.
Oh, I missed part of the error message that may help:
InterfaceError at /feeds/latest_bpostcat/2/ Error binding parameter 0 - probably unsupported type. Request Method: GET Request URL: http://localhost:8000/feeds/latest_bpostcat/2/ Exception Type: InterfaceError Exception Value: Error binding parameter 0 - probably unsupported type. Exception Location: C:\Python25\lib\site-packages\django\db\backends\sqlite3\base.py in execute, line 133 Python Executable: C:\Python25\python.exe Python Version: 2.5.1 Python Path: ['C:\\Documents and Settings\\Greg Taylor\\eclipse_workspace\\gsite', 'C:\\WINDOWS\\system32\\python25.zip', 'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib\\lib-tk', 'C:\\Python25', 'C:\\Python25\\lib\\site-packages', 'C:\\Python25\\lib\\site-packages\\Numeric', 'C:\\Python25\\lib\\site-packages\\PIL'] Environment: Request Method: GET Request URL: http://localhost:8000/feeds/latest_bpostcat/2/ Django Version: 0.97-pre-SVN-7054 Python Version: 2.5.1 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'apps.blog', 'apps.pages'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware') Traceback: File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in get_response 82. response = callback(request, *callback_args, **callback_kwargs) File "C:\Python25\lib\site-packages\django\contrib\syndication\views.py" in feed 19. feedgen = f(slug, request).get_feed(param) File "C:\Python25\lib\site-packages\django\contrib\syndication\feeds.py" in get_feed 105. for item in self.__get_dynamic_attr('items', obj): File "C:\Python25\lib\site-packages\django\db\models\query.py" in __iter__ 114. return iter(self._get_data()) File "C:\Python25\lib\site-packages\django\db\models\query.py" in _get_data 483. self._result_cache = list(self.iterator()) File "C:\Python25\lib\site-packages\django\db\models\query.py" in iterator 189. cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") + ",".join(select) + sql, params) File "C:\Python25\lib\site-packages\django\db\backends\util.py" in execute 18. return self.cursor.execute(sql, params) File "C:\Python25\lib\site-packages\django\db\backends\sqlite3\base.py" in execute 133. return Database.Cursor.execute(self, query, params) Exception Type: InterfaceError at /feeds/latest_bpostcat/2/ Exception Value: Error binding parameter 0 - probably unsupported type.