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

212
Vistas
Python Eve, how to replace a 'dict' with a PATCH request

I am using Python Eve, which is awesome, however I ran into a problem and not sure if there is a solution.

I have a 'fields' dict in this schema:

'profiles': {
  'fields': {
    'type': 'dict',
    'default': {}
  }
}

I'd like to be able to PATCH update the 'fields' field, but the issue is that a PATCH request will never REMOVE any field inside 'fields', but I cannot use a PUT command or else all my other profile fields (not shown above) will disappear.

I tried using a subresource like this:

'profile-fields': {
  'schema': {
    'fields': {
      'type': 'dict',
      'default': {}
    }
  },
  'datasource': {
    'source': 'profiles',
    'projection': { 'fields': 1 }
  }
},

but as the Python Eve documentation states:

Please note that POST and PATCH methods will still allow the whole schema to be manipulated http://python-eve.org/config.html#multiple-api-endpoints-one-datasource

Anyone know of a way to do this?

For Example:

# Create a record
POST /api/profiles
{
  'name': 'Test',
  'fields': {
    'one': 1,
    'two': 2
  }
}
# => { _created: 'blah', _id: '123456' }

# then update fields with a PATCH request
PATCH /api/profiles/123456
{
  'fields': {
    'three': 3,
    'four': 4
  }
}

# then get the updated record
GET /api/profiles/123456
# RESPONSE
{
  '_id': '123456',
  'name': 'Test',
  'fields': {
    'one': 1,
    'two': 2,
    'three': 3,
    'four': 4
  }
}

I have just conceded to using a PUT request and sending the entire object back again, which is ok I guess, just thought there might be a way to do this.

over 4 years ago · Santiago Trujillo
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