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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:36:45+00:00 2026-06-02T21:36:45+00:00

Hi I am using App Engine/Python to do a simple website. I have some

  • 0

Hi I am using App Engine/Python to do a simple website. I have some trouble with a Django template problem.

In short, I want to use a “ShortName” to access a “LongName”.

The soource code:

LongName={"so":"stackoverflow","su":"superuser"}
ShortName=['so','su']

Then I pass these two parameters to the templates.

In the template I write:

{% for aname in ShortName %}
{{ aname }} stands for {{ LongName.aname }},
{% endfor %}

The output is:

so stands for, su stands for

No error is given. The LongName.aname wont work.

I have no idea whats wrong.

  • 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-02T21:36:47+00:00Added an answer on June 2, 2026 at 9:36 pm

    This is trying to access LongName['aname'], not LongName[aname].

    You might have to write a custom template tag/filter to get this to work. This Django bug (marked WONTFIX) has a simple implementation:

    def get(d, key):
        return d.get(key, '')
    
    register.filter(get)
    

    which you would use by

    {{ LongName|get:aname }}
    

    after adding it to your app (that SO answer shows how to do it on GAE).


    You could also pre-make a variable to loop over in the view, by passing in

     # in view
     name_abbrevs = [(k, LongName[k]) for k in ShortName]
    
     # in template
     {% for short_name, long_name in name_abbrevs %}
         {{ short_name }} stands for {{ long_name }}
     {% endif %}
    

    If you really don’t want to add a template tag — which isn’t that bad! you just make one file! 🙂 — or pass in an extra variable, Vic’s approach will let you do this without touching the Python files at all. As he mentions, it involves a lot of pointless iteration, but it’ll work fine for small lists.

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

Sidebar

Related Questions

I have created a simple python web site using Google App Engine. Currently, the
I'm using Google App Engine python. I want to know what browser the user
Using Django templates in Google App Engine (on Python), is it possible to compare
I have some python code for Google App Engine that responds with the string
I wrote a simple webapp using google app engine in python that allows users
I am developing an application on the Google App Engine using Python. I have
I'm new to python, django and google app engine. All great tools and have
As the title suggests, I'm using Google App Engine and Django. I have quite
I'm using App Engine python to host an application and would love to use
I am learning to create a website using google app engine with python and

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.