Fixed lambda serialization error
This commit is contained in:
		| @@ -0,0 +1,20 @@ | |||||||
|  | # Generated by Django 3.0.8 on 2020-07-28 07:38 | ||||||
|  |  | ||||||
|  | from django.db import migrations | ||||||
|  | import django_thumbs.fields | ||||||
|  | import lostplaces_app.models | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class Migration(migrations.Migration): | ||||||
|  |  | ||||||
|  |     dependencies = [ | ||||||
|  |         ('lostplaces_app', '0004_auto_20200727_1803'), | ||||||
|  |     ] | ||||||
|  |  | ||||||
|  |     operations = [ | ||||||
|  |         migrations.AlterField( | ||||||
|  |             model_name='placeimage', | ||||||
|  |             name='filename', | ||||||
|  |             field=django_thumbs.fields.ImageThumbsField(max_length=50, sizes=({'code': 'thumbnail', 'wxh': '390x390'}, {'code': 'hero', 'wxh': '700x700'}, {'code': 'large', 'wxh': '1920x1920'}), upload_to=lostplaces_app.models.generate_image_upload_path), | ||||||
|  |         ), | ||||||
|  |     ] | ||||||
| @@ -17,9 +17,12 @@ class Place (models.Model): | |||||||
|     def __str__(self): |     def __str__(self): | ||||||
|         return self.name |         return self.name | ||||||
|  |  | ||||||
|  | def generate_image_upload_path(instance, filename): | ||||||
|  |     return 'places/' + str(uuid.uuid4())+'.'+filename.split('.')[-1] | ||||||
|  |  | ||||||
| class PlaceImage (models.Model): | class PlaceImage (models.Model): | ||||||
|     filename = ImageThumbsField( |     filename = ImageThumbsField( | ||||||
|         upload_to=lambda instance, filename: 'places/' + str(uuid.uuid4())+'.'+filename.split('.')[-1], |         upload_to=generate_image_upload_path, | ||||||
|         max_length=50, |         max_length=50, | ||||||
|         sizes = ( |         sizes = ( | ||||||
|             {'code': 'thumbnail', 'wxh': '390x390'}, |             {'code': 'thumbnail', 'wxh': '390x390'}, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user