From 9853cecabb35bb88c239b189949c97ef2cdf7602 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Mon, 16 Mar 2020 14:48:04 +0100 Subject: [PATCH] fixed keywords without icons --- cookbook/models.py | 7 +++++-- cookbook/templates/recipe_view.html | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cookbook/models.py b/cookbook/models.py index cb3a6d17d..ea2332d94 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -74,7 +74,10 @@ class Keyword(models.Model): updated_at = models.DateTimeField(auto_now=True) def __str__(self): - return "{0} {1}".format(self.icon, self.name) + if self.icon: + return f"{self.icon} {self.name}" + else: + return f"{self.name}" class Recipe(models.Model): @@ -99,7 +102,7 @@ class Recipe(models.Model): @property def all_tags(self): - return ' '.join([(x.icon + x.name) for x in self.keywords.all()]) + return ' '.join([(str(x)) for x in self.keywords.all()]) class Unit(models.Model): diff --git a/cookbook/templates/recipe_view.html b/cookbook/templates/recipe_view.html index 3fca0f352..c79df2782 100644 --- a/cookbook/templates/recipe_view.html +++ b/cookbook/templates/recipe_view.html @@ -70,11 +70,12 @@ {% if recipe.internal %} {% trans 'by' %} {{ recipe.created_by.username }}
-
{% endif %} - {% if recipe.all_tags %} - {{ recipe.all_tags }} + {% if recipe.keywords %} + {% for x in recipe.keywords.all %} + {{ x }} + {% endfor %}

{% endif %}