Python 找不到Django的Url

Python 找不到Django的Url,python,django,templates,views,urlconf,Python,Django,Templates,Views,Urlconf,所以我有点麻烦。当我尝试访问某个型号的url时,我得到了404: url(r'^rewards/(?P<slug>[-\w]+)/$', RedeemReward.as_view(), name="reward"), url(r'^rewards/(?P<slug>[-\w]+)/$', CompanyDetail.as_view(), name="company"), 这是怎么回事?两个视图的模式是相同的,因此永远不能调用CompanyDetail视图。相反,的模式匹

所以我有点麻烦。当我尝试访问某个型号的url时,我得到了404:

url(r'^rewards/(?P<slug>[-\w]+)/$', RedeemReward.as_view(), name="reward"),
url(r'^rewards/(?P<slug>[-\w]+)/$', CompanyDetail.as_view(), name="company"),

这是怎么回事?

两个视图的模式是相同的,因此永远不能调用
CompanyDetail
视图。相反,
的模式匹配所有slug,并为不匹配其模型类的slug提高404。(可能是
奖励
)在URL中添加一些内容,以区分公司URL和奖励URL。

这两个视图的模式是相同的,因此永远无法调用
公司详细信息
视图。相反,
的模式匹配所有slug,并为不匹配其模型类的slug提高404。(可能是
奖励
)在URL中添加一些内容,以区分公司URL和奖励URL

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