Login

Tag "save file"

Snippet List

get and image object

I use this snippet to save images to my imagefields on django models. This uses the very awesome requests library, so install it first pip install requests You probably want to have this be done on a celery queu, if the image is big enough.

  • imagefield
  • save file
  • save url
Read More

Save image in field

Small function that i use to save files to an imagefield, the file can be either an url or a file. This function has the following requirements. import requests from django.core.files import File from django.core.files.temp import NamedTemporaryFile from django.conf import settings Get the awesome requests library: pip install requests This function uses MEDIA_ROOT to know the location of the static dir, you can change that chaging the static_dir variable.

  • image field
  • save file
Read More

2 snippets posted so far.