I am new to Django and am trying to put the upload file form in the inclusion tag. Therefore, I can use it in different templates.
I created the following inclusion tag:
# upload_files.py
@ register.inclusion_tag ('upload_form.html')
def upload_handler (context):
request = context ['request']
view_url = reverse ('upload.views.upload_handler')
if request.method == 'POST':
form = UploadForm (request.POST, request.FILES)
if form.is_valid ():
form.save ()
return HttpResponseRedirect (view_url)
upload_url, upload_data = prepare_upload (request, view_url)
form = UploadForm ()
upload_model_list = UploadModel.objects.all (). order_by ('- pub_date')
I want to include this in the template, so on the page I have:
# mypage.html
{% extends 'base.html'%}
{% load upload_files%}
{% upload_handler%}
I get the following error:
upload_handler takes 1 arguments
What argument should I pass from the template?
source share