django-rest-framework manually modify the return value of the image field
1. Enter rest-framework.fields
- There is an ImageField (FileField) in it, enter FileField, find its to_represent method, or rewrite it in ImageField, the return url inside is the address of the returned ImageField object
- ImageField.url is to return the full url path
- ImageField.name is the url path returned to the store
- After changing here, the return value of rest-framework's serializer will change.
Mainly because: I have a requirement in my project to put a complete url to reference external images, while django-rest-framework can only return the url he spliced to you