Display an image from a URL in Django

Viewed 267

I am creating a webpage in Django. In a Django form I would like a user to be able to provide an image using a URL. I need to save this information and render this image in a html. How should I do this?

1 Answers

Well you can try this way Steps -

  1. First create a model in models.py with a URL field (something like image_url = models.URLField(max_length=200, **options)
  2. Then render a form wherein you take the input(of the URL) and save the input in the model field.
  3. Now you can use this URL ( which is saved in your db) to display the image
Related