-
Notifications
You must be signed in to change notification settings - Fork 638
Image in profile can't be updated #7
Comments
@priyadhoundiyal One way to keep it consistent is to extend your solution in the following way: You can create a custom field that extends the URL Field. This allows you override the
(I have set the value 'https://static.productionready.io/images/smiley-cyrus.jpg' as a constant in the settings since we are now using this value in two places) Next, in your
I think this is working but do let me know if you run into any problems with it. If someone has a cleaner solution, please share :) |
Can you assign me this task, please? |
Sure @abhinavsharma629, you can create a pull request with changes in the relevant sections |
Instead of using the read-only Serializer method field or a custom made image serializer and returning the image we can return the image URL in the Profile serializer, that would be correct and more efficient while handling a large number of requests for the API. In the next PR, I will implement this. |
Please review the changes. |
On the endpoint {{apiUrl}}/user - the PUT request does not save the image in the user's profile since image field is a SerializerMethodField(which is readonly) in ProfileSerializer.
I was thinking that one way to allow image to be updated could be to remove image as a SerializerMethodField but keep it included in serializer fields like so:
But in this way we end up losing the default image for the profile in the {{apiUrl}}/profiles/ view.
To get the default image in the {{apiUrl}}/user view - we could include image as a SerializerMethodField there
image = serializers.SerializerMethodField()
and define get_image as:
but I don't think it's very consistent if the user endpoint shows a default value for the image but the profile endpoint does not.
Could anyone share another - hopefully consistent - way to do this?
TIA
The text was updated successfully, but these errors were encountered: