2014-12-07 107 views
0

嗨,我做了一些ModelForm。現在當我進入我得到這個錯誤。表單操作不起作用| Django

RuntimeError 
Exception Value:  

You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to 127.0.0.1:8000/comp/new/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings. 

這是什麼造成的?可能表單動作完全匹配URL comp/new的形式,這與我的視圖匹配以呈現和處理數據。但是,出事了....

我的網址

url(r'^comp/new/$', 'company.views.add_company', name='add_company'), 

我的表單操作

<form id="category_form" method="post" action="/comp/new/"> 
+0

它需要一個/最後。你的表單行爲顯然沒有,就像你在你的文章中所說的那樣。/comp/new/- 錯誤消息告訴你到底發生了什麼錯誤。 – Ben 2014-12-07 23:20:47

+0

我試圖把這樣的斜線/ comp/new /放在它上面,但不工作。請求網址:\t http://127.0.0.1:8000/comp/new其不變。 – oranj33 2014-12-07 23:25:24

+1

向我們顯示您的表單代碼 - HTML代碼。 – Ben 2014-12-07 23:31:06

回答

-1

可能是你正在使用reverse所以檢查你的urls.py,缺少/應該有