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 818999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:14:14+00:00 2026-05-15T02:14:14+00:00

In a Django template, is there a way to get a value from a

  • 0

In a Django template, is there a way to get a value from a key that has a space in it?
Eg, if I have a dict like:

{"Restaurant Name": Foo}

How can I reference that value in my template? Pseudo-syntax might be:

{{ entry['Restaurant Name'] }} 
  • 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-05-15T02:14:14+00:00Added an answer on May 15, 2026 at 2:14 am

    There is no clean way to do this with the built-in tags. Trying to do something like:

    {{ a.'Restaurant Name'}} or {{ a.Restaurant Name }}
    

    will throw a parse error.

    You could do a for loop through the dictionary (but it’s ugly/inefficient):

    {% for k, v in your_dict_passed_into_context %}
       {% ifequal k "Restaurant Name" %}
           {{ v }}
       {% endifequal %}
    {% endfor %}
    

    A custom tag would probably be cleaner:

    from django import template
    register = template.Library()
    
    @register.simple_tag
    def dictKeyLookup(the_dict, key):
       # Try to fetch from the dict, and if it's not found return an empty string.
       return the_dict.get(key, '')
    

    and use it in the template like so:

    {% dictKeyLookup your_dict_passed_into_context "Restaurant Name" %}
    

    Or maybe try to restructure your dict to have “easier to work with” keys.

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

Sidebar

Related Questions

Say I have an integer value that I output to a django template say
i have a django template - one that is normally loaded via a standard
I have a Django template that I want to extend in multiple places. In
Is there any way to get the model name of any objects in django
I'd like to get all the django form fields that passed the validation to
I'm using Django 1.2.4. I have an admin class for a model that has
In a Django template, is there a way to convert a float into an
I have a Django Model that implements a time range, like this: class Period(models.Model):
I have a models in Django that are something like this: class Classification(models.Model): name
Possible Duplicate: Django view - load template from calling app's dir first I have

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.