Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!