Skip to content

Commit

Permalink
added images to products model
Browse files Browse the repository at this point in the history
  • Loading branch information
isntlee committed Dec 4, 2023
1 parent 4ce1f0b commit b964da1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion products/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

@admin.register(models.Product)
class ProducerAdmin(admin.ModelAdmin):
list_display = ('id', 'name', 'description', 'active', 'category', 'producer')
list_display = ('id', 'name', 'description', 'image', 'active', 'category', 'producer')
prepopulated_fields = {'slug': ('name',), }


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.1.7 on 2023-12-04 13:28

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('products', '0004_alter_product_producer'),
]

operations = [
migrations.AddField(
model_name='product',
name='image',
field=models.URLField(blank=True, null=True),
),
migrations.AlterField(
model_name='product',
name='active',
field=models.BooleanField(default=True),
),
migrations.AlterField(
model_name='product',
name='slug',
field=models.SlugField(max_length=250),
),
]
1 change: 1 addition & 0 deletions products/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def get_queryset(self):
description = models.TextField()
producer = models.CharField(max_length=250)
slug = models.SlugField(max_length=250)
image = models.URLField(max_length = 200, null=True, blank=True)
produced = models.DateTimeField(default=timezone.now)
active = models.BooleanField(default=True)
objects = models.Manager()
Expand Down
2 changes: 1 addition & 1 deletion products_api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
class ProductSerializer(serializers.ModelSerializer):
class Meta:
model = Product
fields = ('id', 'name', 'description', 'active', 'slug', 'category', 'producer')
fields = ('id', 'name', 'description', 'active', 'slug', 'image', 'category', 'producer')

0 comments on commit b964da1

Please sign in to comment.