Ubuntu12.04でPython2.7を使用してDjango1.4を使用しています。
私は以前に多くのビューを書いたことがありますが、なぜこれで404エラーが発生するのかについて少し困惑しています。
urls.py:
url(r'^addNewClient/', 'gateway_interface.views.add_new_client'),
views.py
def add_new_client(request):
"""
.. function:: add_new_client()
Provide a form for entering new client information
:param request: Django Request object
"""
## Create a logging object
path = os.path.join(os.path.dirname(__file__), 'logs/')
filename = '{0}addNewClient.log'.format(path)
logfile = open(filename, 'a')
now = datetime.datetime.now()
logfile.write('\n --------------------- {0}\n'.format(now))
try:
form = addClientInfo()
except:
output = "Handle Error: Cannot create a valid form"
logfile.write('{0}\n'.format(output))
logfile.write('{0}\n\n'.format(traceback.format_exc()))
logfile.close()
return HttpResponse(output)
try:
data = {}
data.update(csrf(request))
data.update({ 'form' : form })
except:
output = "Handle Error: Cannot generate CSRF token"
logfile.write('{0}\n'.format(output))
logfile.write('{0}\n\n'.format(traceback.format_exc()))
logfile.close()
return HttpResponse(output)
return render_to_response("addNewClientInfo.html", data)
forms.py
class addClientInfo(forms.Form):
"""
.. class:: addClientInfo
Create a form to enter new client info
"""
my_gateway_choices = tuple(gateway_proper_names.items())
# Create the post fields
tkz_client_name = forms.CharField(max_length = 50, required = True)
tkz_gateway = forms.ChoiceField(widget = forms.Select(), choices = my_gateway_choices, required = True)
tkz_gateway_api_id = forms.CharField(max_length = 50, required = True)
tkz_gateway_trans_key = forms.CharField(max_length = 50, required = True)
tkz_ys_api_id = forms.CharField(max_length = 50, required = True)
tkz_ys_trans_key = forms.CharField(max_length = 50, required = True)
何かご意見は?
編集1:
エラーログに情報が表示されないことをお伝えしておきます。.htmlファイルは、他のすべてのテンプレートと一緒に...同じ場所に存在します。