Django-Url错误

时间:2015-10-01 05:57:32

标签: django django-views django-urls

def test(request, arg1, arg2):
   c = [[calendar.month_name[(i.date).month],i.count] for i in    
   Model_name.objects.filter(worker = arg1, process = arg2)]
   c.insert(0,['Month', 'Counts']) # It's for Chart Purpose
   return render_to_response('test3.html', {'array': json.dumps(array3)})

这是我的观点和网址

url(r'^test/(?P<ass_name>/<process_name>\w+)/$', 'model_name.views.test', name='test') 

引发了我404错误。有什么建议吗?

1 个答案:

答案 0 :(得分:1)

这里有几个问题:

  1. 您无法合并多个网址参数。

  2. 网址参数名称必须与视图的参数名称相同。

  3. 因此,请将您的网址更改为:

    url(r'^test/(?P<ass_name>\w+)/(?P<process_name>\w+)/$', 'model_name.views.test', name='test')
    

    你的观点对此起作用:

    def test(request, ass_name, process_name):