Snippet List
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
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.
2 snippets posted so far.