Skip to content

Commit

Permalink
cleanup ids in import as well
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Jul 20, 2020
1 parent 9510562 commit 782d276
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cookbook/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ def create(self, validated_data):
obj, created = Food.objects.get_or_create(**validated_data)
return obj

def update(self, instance, validated_data):
return super(FoodSerializer, self).update(instance, validated_data)

class Meta:
model = Food
fields = ('id', 'name', 'recipe')
Expand Down
2 changes: 1 addition & 1 deletion cookbook/views/import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def import_recipe(request):
form = ImportForm(request.POST)
if form.is_valid():
try:
data = json.loads(form.cleaned_data['recipe'])
data = json.loads(re.sub(r'"id":([0-9])+,', '', form.cleaned_data['recipe']))

sr = RecipeSerializer(data=data)
if sr.is_valid():
Expand Down

0 comments on commit 782d276

Please sign in to comment.