ソースを参照

change description max length

ilya_shyian 2 年 前
コミット
947aba85f6

+ 28 - 0
store_back/apps/goods/migrations/0007_alter_goodimage_options_alter_good_description_and_more.py

@@ -0,0 +1,28 @@
+# Generated by Django 4.0.4 on 2022-07-20 13:39
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('goods', '0006_goodimage_alter_good_images_goodimage_good_and_more'),
+    ]
+
+    operations = [
+        migrations.AlterModelOptions(
+            name='goodimage',
+            options={'ordering': ('order',)},
+        ),
+        migrations.AlterField(
+            model_name='good',
+            name='description',
+            field=models.CharField(blank=True, default='', max_length=5000, verbose_name='description'),
+        ),
+        migrations.AlterField(
+            model_name='goodimage',
+            name='good',
+            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='GoodImages', to='goods.good'),
+        ),
+    ]

+ 1 - 1
store_back/apps/goods/models.py

@@ -13,7 +13,7 @@ class Image(models.Model):
 class Good(models.Model):
     _id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
     name = models.CharField('name',default="", max_length = 200,blank=True)
-    description = models.CharField('description',default="", max_length = 1000,blank=True)
+    description = models.CharField('description',default="", max_length = 5000,blank=True)
     price = models.IntegerField("price", default=0,blank=True)
     amount = models.IntegerField("amount", default=0,blank=True)
     images = models.ManyToManyField(Image,related_name ="goods", blank = True,through='GoodImage')

+ 8 - 8
store_back/apps/goods/views.py

@@ -124,11 +124,11 @@ def good_upsert(request):
 
 @csrf_exempt
 def image_upsert(request):
-        file = request.FILES.get("photo" , None)
-        if file:
-            image = Image.objects.create(url =file )
-            image.save()
-            serializer = ImageSerializer(image)
-            return JsonResponse({"data":serializer.data}, safe=False)
-        else:
-            return JsonResponse({"data":{}}, safe=False)
+    file = request.FILES.get("photo" , None)
+    if file:
+        image = Image.objects.create(url =file )
+        image.save()
+        serializer = ImageSerializer(image)
+        return JsonResponse({"data":serializer.data}, safe=False)
+    else:
+        return JsonResponse({"data":{}}, safe=False)

+ 20 - 0
store_back/apps/orders/migrations/0010_alter_ordergood_good.py

@@ -0,0 +1,20 @@
+# Generated by Django 4.0.4 on 2022-07-20 13:39
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('goods', '0007_alter_goodimage_options_alter_good_description_and_more'),
+        ('orders', '0009_order_owner'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='ordergood',
+            name='good',
+            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='orderGoods', to='goods.good'),
+        ),
+    ]