Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9123529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:21:45+00:00 2026-06-17T06:21:45+00:00

I have a Django template that looks something like this: {% if thing in

  • 0

I have a Django template that looks something like this:

{% if thing in ['foo', 'bar'] %}
    Some HTML here
{% else %}
    Some other HTML
{% endif %}

The problem is it comes back empty. If I switch to this:

{% if thing == 'foo' or thing == 'bar' %}
    Some HTML here
{% else %}
    Some other HTML
{% endif %}

it works fine. Is there some reason you can’t use x in list in Django templates?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:21:46+00:00Added an answer on June 17, 2026 at 6:21 am

    You can. But you can’t use a list literal in templates. Either generate the list in the view, or avoid using if ... in ....

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a django template that looks like this: <head> <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js type=text/javascript></script> <script
I have a template that looks something like: Main Template, home.html: {% extends framed.html
I have a template in Django with a foor loop that looks roughly like
I have a form in my forms.py that looks like this: from django import
So I'm using django and I have a page/template that looks like (simplified to
I have a Django model that looks like this: class City(models.Model): country = models.CharField(max_length=50)
I have a dictionary with embedded objects, which looks something like this: notes =
The master template in my Django app looks like this: {% block parent %}
In Django template I have printed out data like this: P.place = '{{place.json|safe}}'; Then
I have a template that looks like: <form method=post action={% url ... %}> {%

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.