name images with uuid instead of recipe ids
in order to stil be able to manually map images to recipes the name consists of uuid_recipeId.png
This commit is contained in:
parent
0684c47e2a
commit
9179bde8f9
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import uuid
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
import simplejson
|
import simplejson
|
||||||
@ -71,7 +72,7 @@ def internal_recipe_update(request, pk):
|
|||||||
|
|
||||||
im_io = BytesIO()
|
im_io = BytesIO()
|
||||||
img.save(im_io, 'PNG', quality=70)
|
img.save(im_io, 'PNG', quality=70)
|
||||||
recipe.image = File(im_io, name=(str(recipe.pk) + '.png'))
|
recipe.image = File(im_io, name=f'{uuid.uuid4()}_{recipe.pk}.png')
|
||||||
elif 'image' in form.changed_data and form.cleaned_data['image'] is False:
|
elif 'image' in form.changed_data and form.cleaned_data['image'] is False:
|
||||||
recipe.image = None
|
recipe.image = None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user