0

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.

Community
  • 1
  • 1
Zeinab Abbasimazar
  • 9,835
  • 23
  • 82
  • 131

1 Answers1

0

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.

bpgergo
  • 15,669
  • 5
  • 44
  • 68
  • Django's ImageField, keeps the actual binary on the filesystem anyway. I have no idea what the OP is trying to do. – rantanplan Sep 26 '12 at 08:33
  • i have also found the answer for the error `Attempted access to '\face\sample.gif' denied.` the answer was in this page: http://stackoverflow.com/questions/7869549/how-do-you-configure-a-django-imagefield-with-upload-to-and-media-root-on-webfac – Zeinab Abbasimazar Sep 26 '12 at 12:38