I want to have a link so that i can easily know that inherited class is related to this class object.

In the following SEClass has two subclass inheried using manytomany field. whenever use sent data from react it needs to selected that this instance has

    class educationHistory(models.Model):
        sn = models.CharField(max_length=100, blank=True, null=True)
        degree_name = models.CharField(max_length=100, blank=True, null=True)
        board_or_university = models.CharField(max_length=100, blank=True, null=True)
    class awardsMeritsScholarship(models.Model):
        sn = models.CharField(max_length=100, blank=True, null=True)
        year = models.CharField(max_length=100, blank=True, null=True)
        title = models.CharField(max_length=100, blank=True, null=True)
    class SEClass(models.Model):
        # Education History
        education_history = models.ManyToManyField(educationHistory, blank=True)
        # Awards, Merits and Scholarship
        awardsMeritsScholarship = models.ManyToManyField(awardsMeritsScholarship, blank=True)
    my views.py
    class SEClassView(APIView):
        def get(self, request):
            instances = SEClass.objects.all()
            serializer = SEClassSerializer(instances, many=True)
            return Response(serializer.data)
        def post(self, request, format=None):
            data = request.data
            if not isinstance(data, list):
                return Response(
                    {"error": "Data should be a list of objects."},
            save_data = []
            for item in data:
                education_history_data = item.pop('education_history', [])
                awards_merits_scholarship_data = item.pop('awardsMeritsScholarship', [])
                # Create SEClass instance
                se_class_serializer = SEClassSerializer(data=item)
                if not se_class_serializer.is_valid():
                    return Response(se_class_serializer.errors, status=status.HTTP_400_BAD_REQUEST)
                se_class_instance = se_class_serializer.save()
                # Save educationHistory instances and link to SEClass
                for edu_item in education_history_data:
                    edu_item['se_class_id'] = se_class_instance.id
                    edu_serializer = educationHistorySearilizer(data=edu_item)
                    if edu_serializer.is_valid():
                # Save awardsMeritsScholarship instances and link to SEClass
                for awards_item in awards_merits_scholarship_data:
                    awards_item['se_class_id'] = se_class_instance.id
                    awards_serializer = awardsMeritsScholarshipSearilizer(data=awards_item)
                    if awards_serializer.is_valid():
            return Response(save_data, status=status.HTTP_201_CREATED)

Side note: Please don’t try to describe the entire issue in the title. The title should just be a general statement identify what you’re looking for. Use the body of the post to add the details. Also, when posting code here, enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted. (I’ve taken the liberty of cleaning up what I could.)

You may want to become more familiar with the proper terminology used by Python, Django, and databases. The SEClass model does not have two subclasses and there is no “inheritance” involved.

The SEClass is related to two other models by ManyToMany fields.

Please provide more detail about what you mean by “I want to have a link so that i can easily know that inherited class is related to this class object.”
You may want to try and word it as "If I have an instance of “X”, how do I get the related instances of “Y”? (For whatever models “X” and “Y” may be.)

You should also probably review the docs at: