I need to send some extra information in the get api let say first_name and last_name that are non fields for model in the serializer Django Rest Framework

Submitted 1 year, 10 months ago
Ticket #33
Views 120
Language Other
Priority Urgent
Status Closed

Waiter Task Model


class WaiterTasks(models.Model):
    task_id = models.AutoField(primary_key=True)
    admin = models.ForeignKey(Admins, models.DO_NOTHING, blank=True, null=True)
    waiter = models.ForeignKey('Waiters', models.DO_NOTHING, blank=True, null=True)
    task_description = models.CharField(max_length=50, blank=True, null=True)
    date = models.DateTimeField(db_column='Date',auto_now_add=True)  # Field name made lowercase.

    def __str__(self):
        return self.task_id

    class Meta:
        managed = False
        db_table = 'waiter_tasks'



class WaiterTasksSerializer(serializers.ModelSerializer):

    class Meta:


in views.py


class WaiterTaskslist(APIView):

    def get(self,request):
        serializer=WaiterTasksSerializer(taskslist, many=True)
        return Response(serializer.data)
    def post(self):


Submitted on Jul 03, 20
add a comment

1 Answer

you can add something like this in your serializers.py username = CharField(source='user.username', read_only=True) user_image = ImageField( source='user.profile.image', read_only=True) Then add this field in field =[]

Submitted 1 year, 10 months ago

user_image = ImageField( source='user.profile.image', read_only=True)

class Meta:
    model = Question
    fields = '__all__'
- arun 1 year, 10 months ago

Wanna Post Ad?
Reach a large group of audience by posting an ad about your business here. For more details
Drop us a Message