12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- from .models import Facultad, Curso, Matricula, ProximoSemestre
- from rest_framework import serializers
-
-
- class FacultadSerializer(serializers.ModelSerializer):
- class Meta:
- model = Facultad
- fields = ('__all__')
-
- def create(self, validated_data):
- instance, created = Facultad.objects.get_or_create(**validated_data)
- # print(instance, created)
- if(created == False):
- print('ya se creo')
- return validated_data
-
-
- class CursoSerializer(serializers.ModelSerializer):
- class Meta:
- model = Curso
- fields = ('__all__')
-
- def create(self, validated_data):
- instance, created = Curso.objects.get_or_create(**validated_data)
- # print(instance, created)
- if(created == False):
- print('ya se creo')
- return validated_data
-
-
- class MatriculaSerializer(serializers.ModelSerializer):
- class Meta:
- model = Matricula
- fields = ('__all__')
-
- def create(self, validated_data):
- instance, created = Matricula.objects.get_or_create(**validated_data)
- # print(instance, created)
- if(created == False):
- print('ya se creo')
- return validated_data
-
-
- class ProximoSemestreSerializer(serializers.ModelSerializer):
- class Meta:
- model = ProximoSemestre
- fields = ('__all__')
-
- def create(self, validated_data):
- instance, created = ProximoSemestre.objects.get_or_create(
- **validated_data)
- # print(instance, created)
- if(created == False):
- print('ya se creo')
- return validated_data
|