Hello and thank your for your help:
Task: The customer leaves text and digit (the number of stars) i must display it on the page. The review - link.
1) Add method to the model:
2) Install the method to my template:
The problem: It works, but i know it is very stupied realization. I was trying to do it with with static files, like (below), but it didn't work.
Could someone suggest me the right way of realization this task?
-- Task: The customer leaves text and digit (the number of stars) i must display it on the page. The review - link.
How i done it:
1) Add method to the model:
class Mention(models.Model):
mentionn = models.ForeignKey(Step, on_delete=models.CASCADE)
mention_text = models.TextField()
mention_digit = models.IntegerField()
def get_star(self):
if self.mention_digit == 1:
return '<img src="../static/bakot/imagination/starfull.ico">'*1
elif self.mention_digit == 2:
return '<img src="../static/bakot/imagination/starfull.ico">'*2
elif self.mention_digit == 3:
return '<img src="../static/bakot/imagination/starfull.ico">'*3
elif self.mention_digit == 4:
return '<img src="../static/bakot/imagination/starfull.ico">'*4
elif self.mention_digit == 5:
return '<img src="../static/bakot/imagination/starfull.ico">'*5
else:
return self.mention_digit
2) Install the method to my template:
<div class="small-12 medium-12 large-6 columns">
<ul class="menu pdding_h44">
<p>{{ men.get_star|safe }}</p>
</ul>
</div>
The problem: It works, but i know it is very stupied realization. I was trying to do it with with static files, like (below), but it didn't work.
return '<img src="{% static "bakot/imagination/starfull.ico" %}">'*3Could someone suggest me the right way of realization this task?
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f1a31410-3959-42a2-9174-27756d7cbda1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment