serializers.py 401 B

123456789101112131415
  1. from django.db import transaction
  2. from rest_framework import serializers
  3. from .models import *
  4. class MarkerSerializer(serializers.ModelSerializer):
  5. def create(self, validated_data):
  6. instance = Marker(**validated_data)
  7. instance.save()
  8. return instance
  9. class Meta:
  10. model = Marker
  11. fields = ("id", "timestamp", "lat", "lng", "alt", "hdop", "speed")
  12. read_only_fields = ("id",)