0
我收到此錯誤:invalid literal for int() with base 10: 'social'
當我嘗試在/ category/social /中打開頁面時。如何修復django中的valueerror無效字面錯誤?
def all_partners(request,category):
p = Content.objects.filter(category_id=category)
return render_to_response('reserve/templates/category.html', {'p':p},
context_instance=RequestContext(request))
class ContentCategory(models.Model):
content_category = models.CharField('User-friendly name', max_length = 200)
def __unicode__(self):
return self.content_category
class Content(models.Model):
category = models.ForeignKey(ContentCategory)
external = models.CharField('User-friendly name', max_length = 200, null=True, blank=True)
host = models.CharField('Video host', max_length = 200, null=True, blank=True)
slug = models.CharField('slug', max_length = 200, null=True, blank=True)
def __unicode__(self):
return self.slug
url(r'^category/(?P<category>[-\w]+)/$', 'all_partners'),
有關如何解決此問題的任何想法?我認爲錯誤在"p = Content..."
行。