誰かが私の問題について私を助けてくれますか、私のページを保存しようとするとエラー404が発生します。これがコーディングです
urls.py
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
(r'^$', PatientView.as_view()),
(r'^patientList/$', PatientView.as_view(), name ="forside"),
(r'^rehab_diab/(?P<pk>\d+)/$', RehabDiabetesView.as_view(), name="rehabDiabetes_view"),
views.py
class RehabDiabetesView(UpdateView):
template_name="rehab_diab.html"
model = RehabDiabetes
form_class = RehabDiabetesForm
def get_context_data(self, **kwargs):
context = super(RehabDiabetesView, self).get_context_data(**kwargs)
context['pk']=self.kwargs['pk']
return context
def get_object(self, queryset = None):
try:
obj = RehabDiabetes.objects.get(owner = Patient.objects.get(id = self.kwargs['pk']))
except:
obj = RehabDiabetes.objects.create(owner = Patient.objects.get(id = self.kwargs['pk']))
return obj
def form_valid(self, form):
form.save()
return HttpResponseRedirect(reverse("forside"))
rehab_diab.html
<form id="content" action="rehabDiabetes_view pk" method="POST" style="opacity: 1; ">
{% csrf_token %}
<input type="submit" value="Gem" class="ui-button ui-widget ui-state-default ui-corner-all" />
-------#残りのコード。
そしてここにエラーがあります
Page not found (404)
Request Method: POST
Request URL: http:xxx.xxx.xxx/rehab_diab/1/rehabDiabetes_view%20pk
Using the URLconf defined in rehab3.urls, Django tried these URL patterns, in this order:
^admin/
^$
^patientList/$ [name='forside']
^rehab_diab/(?P<pk>\d+)/$ [name='rehabDiabetes_view']
The current URL, rehab_diab/1/rehabDiabetes_view pk, didn't match any of these.
行方不明のリンクは何ですか?djangoのim初心者なので理解できません..:(よろしくお願いします。