所以我有点麻烦。当我尝试访问某个型号的 url 时收到 404:
url(r'^rewards/(?P<slug>[-\w]+)/$', RedeemReward.as_view(), name="reward"),
url(r'^rewards/(?P<slug>[-\w]+)/$', CompanyDetail.as_view(), name="company"),
因此,顶部 url 将类似于rewards/amazon-gift card,而底部url 将类似于reward/amazon(显示亚马逊必须提供的所有礼品卡)。奖励网址按预期工作,但当我尝试访问底部网址时得到 404。风景:
class CompanyDetail(DetailView):
model = Company
context_object_name = 'company'
slug_field = 'company_slug'
template_name = 'asdx/companies.html'
def get_rewards(self):
rewards = Reward.objects.filter(company=self.object)
return rewards
def get_context_data(self, **kwargs):
context = super(CompanyDetail, self).get_context_data(**kwargs)
context['rewards'] = self.get_rewards()
return context
这里发生了什么?