1
/accounts/upload_save/ {'form':}にあるTemplateDoesNotExistにエラーが発生しました。 私は "送信" ボタンを置くときTemplateDoesNotExist at/accounts/upload_save/error
urlpatterns = [
url(r'^regist/$', views.regist,name='regist'),
url(r'^regist_save/$', views.regist_save, name='regist_save'),
url(r'^profile/$', views.profile, name='profile'),
url(r'^photo/$', views.photo, name='photo'),
url(r'^upload/(?P<p_id>\d+)/$', views.upload, name='upload'),
url(r'^upload_save/$', views.upload_save, name='upload_save'),
]
profile.htmlが
<div class="container">
<form action="{% url 'accounts:upload_save' %}" method="POST" enctype="multipart/form-data">
{% csrf_token %}
<div class="input-group">
<label class="input-group-btn">
<span class="btn btn-primary btn-lg">
SELECT FILE
<input type="file" style="display:none" name="files[]" multiple>
</span>
</label>
<input type="text" class="form-control" readonly="">
</div>
<div class="form-group">
<input type="hidden" value="{{ p_id }}" name="p_id" class="form-control">
</div>
<div class="form-group">
<input type="submit" value="SEND" class="form-control">
</div>
</form>
</div>
ですviews.py
def upload(request, p_id):
form = UserImageForm(request.POST or None)
d = {
'p_id': p_id,
'form':form,
}
return render(request, 'registration/accounts/photo.html', d)
@csrf_exempt
def upload_save(request):
if request.method == "POST":
form = UploadForm(request.POST, request.FILES)
if form.is_valid():
data = Post()
data.image = request.FILES['image']
data.save()
else:
form = UploadForm()
return render('registration/accounts/photo.html', {'form':form})
class UploadForm(forms.Form):
image = forms.FileField()
などのurls.pyで を書きました、私はブラウザにphoto.htmlを表示したいと思います。しかし、今、エラーが起こる私は
registration/accounts/photo.html
をrender.Iに書きましたが、これを修正する方法を実際に理解することはできません。どうすればよいですか?