What do you want to save?
Add Code snippet
New code examples
-
Other 2022-03-01 09:41:09
DateTimeField change format
class UserSerializer(serializers.ModelSerializer): date_joined = serializers.DateTimeField(format="<Your format>") class Meta: model = User fields = ('username', 'email', 'first_name', 'last_name', 'is_superuser', 'is_staff', '... Add solution -
Other 2022-01-31 12:56:49
How to save a ManyToManyField as a value instead of id
class Symptoms(DynamicSerializer): class Meta: model = models.Symptom fields = ('name',) #< instead of id use other value class PatientProfiel(DynamicSerializer): symptoms = SymptSer(many=True) #< it it here class Meta... Add solution -
Python 2021-11-04 10:03:07
set value through serializer django
class VariableSerializer(serializers.ModelSerializer): owner_name = serializers.Field(source='owner_id.owner_name') class Meta: model = Varmst resource_name = 'varmst' fields = ('varmst_id', 'varmst_type', 'varmst_name', '... Add solution -
Python 2021-11-02 13:18:08
django many to many post update method via rest
class GroupMembershipSerializer(ModelSerializer): class Meta: model = Membership fields = ('person',) class GroupCreateSerializer(ModelSerializer): memberships = GroupMembershipSerializer(many=True, required=False) def creat... Add solution -
Best helpers
Ranking is empty