Open leros opened 5 years ago
so, if you are still looking for solution, then you have to comment out @pre_load
decorator in
profile's serializer.py
. this will give you and error, that is solved by adding author=None
as an argument to article view function make_article
. this makes adding articles possible, user is set.
you can remove the @pre_load
decorator from user/serializer.py
, this will show you an error 422. i'm still struggling with it.
serializers for user
and profile
assume that every time frontend sends {'user': #payload } or {'profile': #payload }
, but update and create article send only dict with payload keyvals.
so solution is to check if the user
and profile
key is in data, in functions decorated with pre_load
(do something like this: return data.get('profile', data)
)
still, add that author=None
to make_article
.
for updating, you also need to allow for password to be empty in UserSchema.
( password = fields.Str(load_only=True, allow_none=True)
)
I think it need new schema for updating user profile.
I am running the app in dev model. I tried to add a new article for a new user and got
KeyError: 'profile'
which was due to a problem of this code:Also, I got another key error when trying to update user profile: