From a6f34417615d498dc5155f06cd42b24e73628490 Mon Sep 17 00:00:00 2001 From: SandraBergstrom Date: Fri, 28 Apr 2023 14:27:55 +0000 Subject: [PATCH] Issue #27 - Update recipe model with cloudinary img link as default --- .../0009_alter_recipe_featured_image.py | 19 +++++++++++++++++++ cookbook/models.py | 4 +--- .../templates/cookbook/recipe_detail.html | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 cookbook/migrations/0009_alter_recipe_featured_image.py diff --git a/cookbook/migrations/0009_alter_recipe_featured_image.py b/cookbook/migrations/0009_alter_recipe_featured_image.py new file mode 100644 index 0000000..3f71ae0 --- /dev/null +++ b/cookbook/migrations/0009_alter_recipe_featured_image.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.18 on 2023-04-28 13:56 + +import cloudinary.models +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0008_alter_recipe_about'), + ] + + operations = [ + migrations.AlterField( + model_name='recipe', + name='featured_image', + field=cloudinary.models.CloudinaryField(default='https://res.cloudinary.com/sandrabergstrom/image/upload/v1682690083/placeholder_got9h5.jpg', max_length=255, verbose_name='image'), + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index 06347ec..47ae6e5 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -8,11 +8,9 @@ class Recipe(models.Model): - placeholder = 'static/cookbook/images/placeholder.jpg' - title = models.CharField(max_length=200) author = models.ForeignKey(User, on_delete=models.CASCADE) - featured_image = CloudinaryField('image', default='placeholder') + featured_image = CloudinaryField('image', default='https://res.cloudinary.com/sandrabergstrom/image/upload/v1682690083/placeholder_got9h5.jpg') excerp = models.CharField(max_length=200, blank=True, null=True) about = models.TextField(max_length=600, blank=True, null=True) category_choices = [ diff --git a/cookbook/templates/cookbook/recipe_detail.html b/cookbook/templates/cookbook/recipe_detail.html index 4ac7c55..69f511c 100644 --- a/cookbook/templates/cookbook/recipe_detail.html +++ b/cookbook/templates/cookbook/recipe_detail.html @@ -4,7 +4,7 @@
- Image of recipe