You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
imagine I have a profile linked to my user and I want to expose only one route (/users/) to patch the twos, is it actually possible ?
Seems like the actual implementation isn't compatible ? is it ?
I created two tuples and merged them with :
PATH_CHOICES = USER_CHOICES (as /%s) + PROFILE_CHOICES (as /profile/%s)
But I get this error :
marshmallow.exceptions.ValidationError: Field 'parts_number' does not exist, so it cannot be patched
The text was updated successfully, but these errors were encountered:
@classmethoddefreplace(cls, obj, field, value, state):
if'profile/'infield:
sub_obj, sub_field=field.split('/')
sub_obj=getattr(obj, sub_obj)
ifhasattr(sub_obj, sub_field):
obj=sub_objfield=sub_fieldifnothasattr(obj, field):
raiseValidationError("Field '%s' does not exist, so it cannot be patched"%field)
setattr(obj, field, value)
returnTrue
This is obviously temporary and hard-coded for my specific use case.
But in the future I'll probably need it for more modules, and will make a PR if I have the time !
@askz I am sorry for the late response! I think, your case is quite legal, though I had never had such a requirement yet. I will be happy to accept a PR. Your ad-hoc implementation is quite reasonable to me.
imagine I have a profile linked to my user and I want to expose only one route (/users/) to patch the twos, is it actually possible ?
Seems like the actual implementation isn't compatible ? is it ?
I created two tuples and merged them with :
PATH_CHOICES = USER_CHOICES (as /%s) + PROFILE_CHOICES (as /profile/%s)
But I get this error :
The text was updated successfully, but these errors were encountered: