MongoEngine / MongoEngine/mongoengine
ImageField returns Null with DRF
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4h 41m
- Merged PRs (30d)
- 11
Description
I am using DRF v3 and mongoengine.
In my Mongodb, image field has been well inserted like ("image_file" : ObjectId("57ff54681d41c8bf44ddc047")
However, when I use the DocumentSerializer of DRF, it returns "image_file": null.
I uploaded this issue on the DRF mongoengine forum.
Looks like mongoengine's ImageField doens't go well with DRF mongoengine's ImageField.
I don't know which one is problem.
This is the source code.
from rest_framework_mongoengine.serializers import DocumentSerializer
from ..models import *
class Detail_computer_Serializer(DocumentSerializer):
class Meta:
model = Item_Detail
from django_mongoengine import Document, EmbeddedDocument
class ItemDetail(Document):
image_file = ImageField()
in Django view.py
def image_upload(request):
item.image_file = request.FILES['image_file']
....
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the shown DocumentSerializer, the ItemDetail ImageField, and the Django view assignment, then reproduce the DRF v3 and mongoengine setup described. Compare the stored MongoDB ObjectId with the serializer's field handling and determine whether the value is lost in mongoengine or DRF mongoengine. Done means the image_file value is serialized instead of returned as null.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, python
- Domain
- api, backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100