My user object with rest framework has an avatar_id
and a cover_id
. But Instead of displaying that to the API, I want it to be the actual avatar URL and cover URL already.
My User
model:
avatar_id = models.IntegerField()
cover_id = models.IntegerField()
My UserAvatar
model:
id = models.IntegerField(primary_key=True)
user_id = models.IntegerField()
file_id = models.IntegerField()
My Files
model:
id = models.IntegerField(primary_key=True)
filename = models.CharField(max_length=255)
Same concept with UserCover
.
How do I remove the avatar_id
from the results of /users/
and add a avatar field with the actual avatar filename?
I'm not sure I understand your question correctly, but here what I think the problems are. Reading your question, I assumed that you are a beginner, so I answered as such. Sorry if it's not the case.
I don't know what is a
UserCover
, but here's what your models could look like:Or like this if a will be reused often :