Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
Python Django - Uploading a file from the shell

I am trying to upload a file from a shell to one of my django models in the following manner:

a = Post(name=name, content=content)
a.attachment.save('some.pdf', File(open('some.pdf', 'r')))        

But I keep getting the following error: TypeError: must be convertible to a buffer, not FieldFile. I looked at other posts and could not find any solution that solves this problem.

I am using Python 2.7 and Django 1.10. I would really appreciate any help.

EDIT: The problem was not with the way I was storing the file but was with my post-save signals. Sorry and thanks for your help!

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

try:

f = open('some.pdf', 'r')
a.attachment = File(f)
a.save()
f.close()
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda