Question

i have an image filed in my model and i want to write SQL create table queries myself my model filed is this:

pic = models.ImageField(u"initial_picture",blank=True,upload_to="/face")

and i wanna use command CREATE TABLE SOME_TABLE_NAME to create my table but i don't know what should i use for the field type i'v read here that i can use something like this:

Photo varbinary(max) not null

but i don't know if it's compatible for django and if it's appropriate for my model i also have used pic IMAGE DEFAULT NULL like what i saw here and the result was a varchar(100) field in the database structure

any help will be appriciated ;-)

i'v tried both Photo varbinary(max) not null and Photo varchar(max) not null the field is showing but when i press save, i get the following error:

Attempted access to '\face\sample.gif' denied.

Was it helpful?

Solution

Why don't you keep the images in the file system, as plain files? This would be the corresponding SQL

`pic` varchar(100) NOT NULL,

for your pic field.

pic = models.ImageField(u"initial_picture",blank=True,upload_to="/face")

In the database, the pic field would only contain the path for the actual image file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top