No Description

serializers.py 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <<<<<<< HEAD
  2. from .models import Facultad, Curso, Matricula
  3. =======
  4. from .models import Facultad, Curso, Matricula, ProximoSemestre
  5. >>>>>>> Suazo
  6. from rest_framework import serializers
  7. class FacultadSerializer(serializers.ModelSerializer):
  8. class Meta:
  9. model = Facultad
  10. fields = ('__all__')
  11. def create(self, validated_data):
  12. instance, created = Facultad.objects.get_or_create(**validated_data)
  13. # print(instance, created)
  14. if(created == False):
  15. print('ya se creo')
  16. return validated_data
  17. class CursoSerializer(serializers.ModelSerializer):
  18. class Meta:
  19. model = Curso
  20. fields = ('__all__')
  21. def create(self, validated_data):
  22. instance, created = Curso.objects.get_or_create(**validated_data)
  23. # print(instance, created)
  24. if(created == False):
  25. print('ya se creo')
  26. return validated_data
  27. class MatriculaSerializer(serializers.ModelSerializer):
  28. class Meta:
  29. <<<<<<< HEAD
  30. model = Curso
  31. =======
  32. model = Matricula
  33. >>>>>>> Suazo
  34. fields = ('__all__')
  35. def create(self, validated_data):
  36. instance, created = Matricula.objects.get_or_create(**validated_data)
  37. # print(instance, created)
  38. if(created == False):
  39. print('ya se creo')
  40. return validated_data
  41. <<<<<<< HEAD
  42. =======
  43. class ProximoSemestreSerializer(serializers.ModelSerializer):
  44. class Meta:
  45. model = ProximoSemestre
  46. fields = ('__all__')
  47. def create(self, validated_data):
  48. instance, created = ProximoSemestre.objects.get_or_create(
  49. **validated_data)
  50. # print(instance, created)
  51. if(created == False):
  52. print('ya se creo')
  53. return validated_data
  54. >>>>>>> Suazo