Skip to content

Commit

Permalink
Issue #27 - Update recipe model with cloudinary img link as default
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraBergstrom committed Apr 28, 2023
1 parent f0fbe7d commit a6f3441
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
19 changes: 19 additions & 0 deletions cookbook/migrations/0009_alter_recipe_featured_image.py
Original file line number Diff line number Diff line change
@@ -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'),
),
]
4 changes: 1 addition & 3 deletions cookbook/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion cookbook/templates/cookbook/recipe_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="card mb-3">
<div class="row g-0">
<div class="col-md-4 h-400">
<img src="{{ recipe.featured_image.url }}" class="img-fluid rounded-start" alt="Image of recipe"
<img src="{{ recipe.featured_image.url }}" class="img-fluid rounded-start" alt="Image of {{ recipe.title }}"
style="object-fit: cover; height: 100%; width: 100%" />
</div>
<div class="col-md-8">
Expand Down

0 comments on commit a6f3441

Please sign in to comment.