2015-10-01 45 views
-1
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)}) 

這是我的觀點和URLDjango的網址錯誤

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

拋出我的404。有什麼建議麼?

+0

請回溯發佈錯誤。 –

+0

只是普通的404錯誤'找不到頁面(404)' – Thuruv

+0

你打的是什麼網址? –

回答

1

有幾件事情錯在這裏:

  1. 不能同時使用多個網址參數。

  2. URL參數名稱必須與視圖的參數名稱相同。


所以您的網址改成這樣:

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

而且您的視圖功能是:

def test(request, ass_name, process_name): 
+0

@ Leis:行之有效,但你能解釋一下我還是我可以知道的一種方式? – Thuruv

+1

@Thuruv這一切都在[文檔](https://docs.djangoproject.com/en/1.8/topics/http/urls/#named-groups)。 – Leistungsabfall