1

Hy! I created a new Django project to upload a photo using a FormView. The photo gets processed and a download link is provided. The problem is the response: I want the html page to stay the same, only the download link should be added.

class ColorImageView(FormView):
  template_name = 'images.html'
  form_class = ColorImageForm

  def form_valid(self, form):
    download_link = ....
    return HttpResponse(...?...)

Screenshot

angulardjango
  • 33
  • 1
  • 4

1 Answers1

1

Just edit images.html with something like:

{% if download_link %}
  <a href="{{ download_link }}">Download</a>
{% endif %}

And pass the URL in the view:

def form_valid(self):
    download_link = ''
    return self.render_to_response(self.get_context_data(download_link=download_link))
Gianluca Mancini
  • 1,302
  • 9
  • 10
  • What is the easiest way to show a progress bar while processing? – angulardjango Aug 12 '16 at 09:10
  • An alternative solution would be to use AJAX to submit the form and display the response (download link) on success. Check this link http://www.laurentluce.com/posts/upload-to-django-with-progress-bar-using-ajax-and-jquery/ – Resley Rodrigues Aug 12 '16 at 09:11