Running: Windows 7, Python 3.3, Django 1.6
I'm confused as to how to store an image as part of a table in a Django database. There is a field called ImageField
, and here are the Docs.
Question:
What should I pass to the ImageField when constructing the record: a filepath string? A url to an image? Or a byte representation of the image itself? Or is there some way of loading an image into Django and then just passing it a reference (or pointer) to that image object?
The docs say: "By default, ImageField instances are created as varchar(100) columns in your database.", which leads me to think that it wants a file path since it's asking for a string.
The Docs also say that it "Requires the Pillow library.", which I've downloaded but it doesn't specify how to use Pillow for this.
Background: I'm building a REST API through django to send and recieve log files from Selenium tests and store them in a SQL database. Each log file comes with a screenshot, hence the need for an ImageField. Just started using Django a few days ago.