Created
June 20, 2019 14:28
-
-
Save spinolacastro/17c8d4bd171fdc1fafb0c3ceaa2cdb54 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SERIALIZER | |
class CuentaSerializer(serializers.ModelSerializer): | |
tipo = serializers.StringRelatedField() | |
class Meta: | |
model = Cuenta | |
read_only_fields = ('id', 'saldo',) | |
exclude = ('data', 'activa', 'usuario', 'bind_ref') | |
VIEW | |
##DO SOME OTHER STUFF TO GET THE BODY | |
body = render_to_string('apibank/alta_cvu.txt', context) | |
ret = apibank.alta_cvu(body) | |
cuenta_tipo = CuentaTipo.objects.get(tipo='virtual') | |
datos = { | |
'cvu': ret['cvu'], | |
'alias_cvu': ret['label'], | |
'bind_ref': bind_ref, | |
} | |
request.data.update(datos) | |
serializer = self.get_serializer(data=request.data) | |
serializer.is_valid(raise_exception=True) | |
serializer.save(usuario = request.user, tipo=cuenta_tipo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment