passing information via json (ajax)

hello,
I am trying to retrive information from the server in run time with ajax.
when i send the request i return this object
the_course = course.objects.filter(id=course_id)
course_information = serializers.serialize(‘json’, the_course)
when course is an model :

class course(models.Model):
name = models.CharField(max_length=50)
description = models.CharField(max_length=500)
title_description = models.CharField(max_length=250,default=“”)
course_slug = models.CharField(max_length=50,default=“”)
price = models.FloatField()
blocked_by = models.ManyToManyField(‘course’,related_name=“blocking”,blank=True,default=None)
image = models.ImageField(upload_to=“uploads”,blank=True,default=None)
course_sections = models.ManyToManyField(course_section,related_name=“course”,blank=True)
autor = models.ForeignKey(NewUser, related_name=‘writen_courses’,
on_delete=models.DO_NOTHING, blank=True, null=True)
degree = models.ManyToManyField(degree,related_name=“courses”)
display = models.BooleanField(default=True)

the information i get is displayed like so:


as you can see when the object has many to many relasion ship it return a list of ids, I want it to send a list with a tuple like so [(name,id)]
is it posiible?

thanks.

Is it possible? Yes, but not with the default Django serializer.

You would either need to create your own custom serializer (see Serializing Django objects | Django documentation | Django), build a dictionary yourself with the field values and serialize that, or use something like the Django REST framework. (Admittedly, that is probably more than you need or want to implement for this one situation.)