I am new to Django and am trying to put an upload file form into an inclusion tag. So I can use it in various templates.
I have 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 wish to now include this in a 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 be passing from the template?