Skip to content

Instantly share code, notes, and snippets.

@dpineiden
Created May 5, 2018 20:33
Show Gist options
  • Save dpineiden/c6b8827b94e12405a72be5f2b2214cf9 to your computer and use it in GitHub Desktop.
Save dpineiden/c6b8827b94e12405a72be5f2b2214cf9 to your computer and use it in GitHub Desktop.
Django Image saved with scripting
ruta_img = img_propiedad_tuple[1]
with open(os.path.join(path,ruta_img),'r+b') as im:
imagen = ImageFile(im)
print("Imagen: %s" %imagen)
print("Imagen: %s" %type(imagen))
print("Image opened: %"%im)
new_img_propiedad.imagen = imagen
new_img_propiedad.etiqueta = img_propiedad_tuple[2]
new_img_propiedad.principal = img_propiedad_tuple[3]
new_img_propiedad.propiedad = Propiedad.objects.get(id = IDs['propiedad'][img_propiedad_tuple[4]])
new_img_propiedad.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment