Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

reverse relationship in django for one to one field for usage in Django rest serializer

class UserProfileSerializer(serializers.ModelSerializer):

    class Meta:
        model = UserProfile
        fields = ('id', 'user', 'emp_id', 'department')


class UserPairSerializer(serializers.ModelSerializer):
    profile = UserProfileSerializer(read_only=True, source='userprofile')

    class Meta:
        model = User
        fields = ('id', 'email', 'is_active', 'profile')
Comment

PREVIOUS NEXT
Code Example
Python :: python np array get dimantion 
Python :: datatime add time in float 
Python :: number length python 
Python :: looping through strings 
Python :: get first not null value from column dataframe 
Python :: variable bound to a set python 
Python :: df max count syntax 
Python :: 2d array python 
Python :: keras backend matrix multiplication 
Python :: convert decimal to float in python 
Python :: how to make a new key in a dictionary python 
Python :: join two strings python 
Python :: threadpool python map 
Python :: check whether number is even or odd 
Python :: pytest for loop 
Python :: repeat a condition n times one by one python 
Python :: python black 
Python :: python - sending mail 
Python :: convert int to ascii python 
Python :: list to one hot encoding pandas 
Python :: call shell script from python 
Python :: python open file location 
Python :: change folder icon with python 
Python :: how to round a number up in python 
Python :: tkinter auto resize height 
Python :: python dictionary get vs setdefault 
Python :: pandas index append value 
Python :: how to delete item in string python 
Python :: openpyxl 
Python :: python in kali linux 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =