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

  • Home
  • SEARCH
  • 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 7906371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:55:23+00:00 2026-06-03T10:55:23+00:00

So I have a simple template problem. In a URL view I pass one

  • 0

So I have a simple template problem. In a URL view I pass one var, called ‘style’, and I pass a dictionary with a bunch of model info. To get right too it:

{{ style }}
{% for recipe in recipes %}
    {{ recipe.recipe_style }}
    {% if recipe.recipe_style == style %}
        {{ recipe.recipe_style }}
    {% endif %}
{% endfor %}

So what this block should return is:

Dinner Dinner Dinner Dinner Dinner

because there are only two entries in the recipe model, both with ‘Dinner’ set as the recipe_style (charfields), and the style is passed through the view and urlconf (“r’^(?P[-A-Za-z0-9_]+)/” which grabs ‘Dinner’ from a url ‘http://…/Dinner/’). What it returns is:

Dinner Dinner Dinner

This is because the if statement comes back false. But why? “Dinner” == “Dinner”! My only guess is a format issues? I tried style=str(style) before passing it in the view, but still didn’t work.

EDIT: here’s what shows in the shell:

>>> RecipeStyle.objects.all()
[<RecipeStyle: Dinner>, <RecipeStyle: Lunch>, <RecipeStyle: American>, <RecipeStyle: Italian>, <RecipeStyle: French>]
>>> recipe = Recipe.objects.get(pk=1)
>>> recipe.recipe_style
<RecipeStyle: Dinner>

and it works in the console:

>>> if recipe.recipe_style == RecipeStyle.objects.get(pk=1):
...     print "poop"
... 
poop

So why not in the template?

  • 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-03T10:55:26+00:00Added an answer on June 3, 2026 at 10:55 am

    I was doing it wrong. The if statement I had was filtering a queryset passed to the template; dumb, right? I fixed it by filtering the recipe model in the view and then passing the filtered queryset.

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

Sidebar

Related Questions

I'm trying to write a simple template system, and I have a problem. If
i have a simple template that i populate with some data then im trying
I have simple win service, that executes few tasks periodically. How should I pass
I have simple WinForms application where modifying Windows Registry. The problem is that in
I have a defined a simple template class. In this class I define a
I have a simple style for label controls. I'd like to define a control
I have a simple view function that's designed to allow the user to choose
In a Django template, I have a function function show_graph(i){ $(#+i+seegraph).click(function(){ $(#+i+graph).show(); var qaa
I have a simple set of urls in a Django url conf file which
I've build a simple templating engine for a friend, however i have a problem

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.