0

i have model called "Person" and i want to store profile pictures in database in postgres i use "bytea" type for storing images and in my django model i use "BinaryField"

My model is like this:

class Person(models.Model)
    name = models.TextField(blank=True, null=True)
    photo = models.BinaryField(blank=True, null=True)

My Django serializer:

class PersonSerializer(modelserializer):
    class Meta:
        models = Person
        Fields= '__all__'

And finaly my view :

class PersonView(ModelViewSet):
    queryset= Person.objects.all()
    serializer_class = PersonSerializer

my problem is that when i want to insert data django do not show "photo" field in the view what is my mistake??

Aneesh R S
  • 3,807
  • 4
  • 23
  • 35

1 Answers1

0

BinaryField are not supported by Django REST framework. You'll need to write a serializer field class and declare it in a mapping to make this work.

Linovia
  • 19,812
  • 4
  • 47
  • 48