Django: with arguments '('',)' and keyword arguments '{}' not found
I'm kind of new to django. Been working with it for a while, but still do really silly mistakes all the time. This one though, I seem to have a hard time figuring out... Because I'm sorta new to this I'm not very good at explaining my problem, 开发者_如何学编程but here goes...
Error message complains about this bit in template:
{% url privblog object.id %}
urls.py extract:
urlpatterns = patterns('', url(r'^(?P<object_id>\d+)/$', 'privblog.views.privblog_detail', name="privblog"),)
views.py:
from django.shortcuts import render_to_response
from models import PrivBlog
from blog.models import Blog
from django.template import RequestContext
def privblog_detail(request, object_id=None):
pblog_detail_object = PrivBlog.objects.filter(id=object_id)
pblog_recent_object = PrivBlog.objects.all()[:5]
tblog_recent_object = Blog.objects.all()[:5]
context = {'pblog_detail_object': pblog_detail_object,
'pblog_recent_object': pblog_recent_object,
'tblog_recent_object': tblog_recent_object,
}
return render_to_response('privblog/privblog_detail.html', RequestContext(request, context))
You don't have an object called object in your context:
{% url privblog object.id %}
Should be
{% url privblog pblog_detail_object.id %}
You might also be having trouble here:
return render_to_response('privblog/privblog_detail.html', context, RequestContext(request))
I've never invoked render_to_response that way.
精彩评论