diff --git a/alkatorapi/migrations/0020_alter_product_img.py b/alkatorapi/migrations/0020_alter_product_img.py new file mode 100644 index 0000000..8c2024d --- /dev/null +++ b/alkatorapi/migrations/0020_alter_product_img.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.12 on 2024-10-13 07:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('alkatorapi', '0019_cart_invoice_product_remove_racer_id_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='product', + name='img', + field=models.ImageField(upload_to='photos'), + ), + ] diff --git a/alkatorapi/models.py b/alkatorapi/models.py index 6c20fe1..7bc8671 100644 --- a/alkatorapi/models.py +++ b/alkatorapi/models.py @@ -67,7 +67,7 @@ class Profile(models.Model): class Product(models.Model): name = models.CharField(max_length=120) description = models.TextField() - img = models.CharField(max_length=120) + img = models.ImageField(upload_to="photos") price = models.IntegerField() quantity = models.IntegerField() diff --git a/alkatorapi/views.py b/alkatorapi/views.py index ef5e573..63f774e 100644 --- a/alkatorapi/views.py +++ b/alkatorapi/views.py @@ -333,7 +333,7 @@ def products(request): { 'name': product.name, 'description': product.description, - 'img': product.img, + 'img': product.img.path, 'price': product.price, 'quantity': product.quantity, }