Viral News
Django Python if block on template file (string)
I am trying to ad a condition into an html model in Django (python) and it is not working: This is my HTML: {{ post.author }} {% if post.author == ‘John_Woo’ %} NOK {% else %} ok {% endif %} Not sure what is wrong here… Even though I have a John_Woo author, I only…

I’m looking out to advert a situation into an html mannequin in Django (python) and it is no longer working:
Right here’s my HTML:
{{ submit.author }}
{% if submit.author == 'John_Woo' %}
NOK
{% else %}
sufficient
{% endif %}
Now not definite what’s inappropriate here…
Regardless that I accept as true with a John_Woo author, I perfect receive sufficient message
Right here’s my gadgets.py:
class Publish(gadgets.Model):
title = gadgets.CharField(max_length=200, distinctive=Precise)
slug = gadgets.SlugField(max_length=200, distinctive=Precise)
author = gadgets.ForeignKey(User, on_delete= gadgets.CASCADE,related_name='blog_posts')
Right here’s my views.py:
from django.views import generic
from .gadgets import Publish
class PostList(generic.ListView):
queryset = Publish.objects.filter(scheme=1).order_by('-created_on')
template_name = 'index.html'
class PostDetail(generic.DetailView):
mannequin = Publish
template_name = 'post_detail.html'
requested 24 mins ago
ROCAROCA
357 bronze badges