image field

This commit is contained in:
Martin Quarda 2024-10-13 09:23:13 +02:00
parent 96a9dc1114
commit 96f1933ab4
3 changed files with 20 additions and 2 deletions

View File

@ -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'),
),
]

View File

@ -67,7 +67,7 @@ class Profile(models.Model):
class Product(models.Model): class Product(models.Model):
name = models.CharField(max_length=120) name = models.CharField(max_length=120)
description = models.TextField() description = models.TextField()
img = models.CharField(max_length=120) img = models.ImageField(upload_to="photos")
price = models.IntegerField() price = models.IntegerField()
quantity = models.IntegerField() quantity = models.IntegerField()

View File

@ -333,7 +333,7 @@ def products(request):
{ {
'name': product.name, 'name': product.name,
'description': product.description, 'description': product.description,
'img': product.img, 'img': product.img.path,
'price': product.price, 'price': product.price,
'quantity': product.quantity, 'quantity': product.quantity,
} }