Skip to content

Commit

Permalink
Update instance directly in observation update
Browse files Browse the repository at this point in the history
  • Loading branch information
eleurent committed Oct 15, 2023
1 parent dbabb0b commit b7968ec
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions backend/nature_go/observation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ def update(self, request, *args, **kwargs):
species, created = Species.objects.update_or_create(
scientificNameWithoutAuthor=species_data['scientificNameWithoutAuthor'],
defaults=species_data)

serializer = ObservationSerializer(instance, data=dict(species=species.id))
if serializer.is_valid(raise_exception=True):
serializer.save()
return Response(serializer.data)
instance.species = species
instance.save()
return Response(ObservationSerializer(instance).data)

0 comments on commit b7968ec

Please sign in to comment.