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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:24:00+00:00 2026-06-05T20:24:00+00:00

I have a dictionary with tuples as keys. e.g.: {(‘tags’,’1′): ‘name’, (‘name’,’first’):’rik’, (‘name’,’last’):’atee’} In

  • 0

I have a dictionary with tuples as keys. e.g.: {(‘tags’,’1′): ‘name’, (‘name’,’first’):’rik’, (‘name’,’last’):’atee’}

In django, how do I print the value at (‘name’,’first’), for example? I can do it with dict.items.1, or dict.items.2 – but ordering becomes an issue then.

  • 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-05T20:24:02+00:00Added an answer on June 5, 2026 at 8:24 pm

    The Django templating language is intentionally restrictive in what it allows you to reference.

    For instance you must use the dot operator to access attributes AND dictionary elements which means the keys you reference must be strings.

    From docs:

    Variable names must consist of any letter (A-Z), any digit (0-9), an underscore (but they must not start with an underscore) or a dot.

    https://docs.djangoproject.com/en/dev/ref/templates/api/#variables-and-lookups

    Your options are to either (a) use your view to munge the tuple-keys into a string-format or (b) you can use a different templating engine which allows you to reference with arbitrary keys.

    Option (b) isn’t actually as bad as it sounds as their are templating languages for Django which are designed as a superset to Django’s templating language so (theoretically) all your old templates work and you just get more functionality. I advise you checkout the Jinja templating language, it has the functionality you’re looking for.

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

Sidebar

Related Questions

I have a dictionary named 'score' with keys that are tuples. Each tuple is
I have a dictionary that sometimes receives calls for non-existent keys, so I try
I have a dictionary whose components are all 2-tuples (all integers) and I want
I have a dictionary where keys are strings, and values are integers. stats =
In python I have a dictionary that maps tuples to a list of tuples.
I have a dict with tuples as keys, and I want to obtain the
Consider I have the two following tuples: keys=(second, minute, hour, day) values=(1, 60, 60,
Have Dictionary <Int64, byte> that gets used a lot. I mean in a loop
I have: dictionary = {foo:12, bar:2, jim:4, bob: 17} I want to iterate over
I have dictionary which holds my books: Dictionary<string, book> books Book definiton: class book

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.