Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to display a manytomany field in django rest framework

class ProjectSerializer(serializers.ModelSerializer):

    tag= serializers.StringRelatedField(many=True)

    class Meta:
       model = Song
       fields = '__all__'
Comment

django rest framework show ManyToManyField key value

class AlbumSerializer(serializers.ModelSerializer):
    tracks = serializers.StringRelatedField(many=True)

    class Meta:
        model = Album
        fields = ['album_name', 'artist', 'tracks']
        
https://www.django-rest-framework.org/api-guide/relations/#stringrelatedfield
Comment

PREVIOUS NEXT
Code Example
Python :: get max value column pandas 
Python :: sqlalchemy create engine PostgreSQL 
Python :: python check folder exist 
Python :: primes pytyhon 
Python :: set text and background color in pandas table 
Python :: trimming spaces in string python 
Python :: how to record the steps of mouse and play the steps using python 
Python :: python exe not working on other pc 
Python :: from matrix to array python 
Python :: python link to jpg 
Python :: connecting google colab to local runtime 
Python :: python format decimal 
Python :: nlargest hierarchy series pandas 
Python :: python count distinct letters 
Python :: pandas conditional replace values in a series 
Python :: python utf8 
Python :: print complete dataframe pandas 
Python :: how to write a numpy array to a file in python 
Python :: how to launch an application using python 
Python :: how to rotate plot in jupyter 
Python :: redirect to previous page django 
Python :: python string contains substring 
Python :: pandas group by count 
Python :: python 3.9.5 installed update default version 
Python :: python string cut substring 
Python :: remove character python 
Python :: how to use python to sleep if the user is not using the system 
Python :: pandas strips spaces in dataframe 
Python :: raise python 
Python :: python tkinter frame title 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =