我正在尝试做的是体育类别页面显示链接到曲棍球和运行类别页面。我想我差不多了,但是[<Category: hockey>, <Category: run>]
而不是class Category(models.Model):
name = models.CharField(max_length=128, unique=True)
parent_cat = models.ForeignKey('self', null=True, blank=True)
我想要曲棍球并跑到那里。
<a href="/category/{{something}}">{{category.category_set.all}}</a>
在模板中我有
url(r'^category/(?P<category_name_url>[\w|\W]+)/$', views.category, name='category'),
我的网址
class Category(models.Model):
name = models.CharField(max_length=128, unique=True)
author = models.ForeignKey(settings.AUTH_USER_MODEL)
parent_cat = models.ForeignKey('self', null=True, blank=True)
hotCat = models.BooleanField(default=False)
active = models.BooleanField(default=True)
sponsored = models.ForeignKey(Sponsored, null=True, blank=True)
objects = CategoryManager()
def __unicode__(self):
return self.name
def get_absolute_url(self):
return "/category/%s/" %self.name
def get_image_url(self):
return "%s%s" %(settings.MEDIA_URL, self.image)
有人可以帮助我吗?
编辑:我的完整模特
#define byte unsigned char