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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:11:39+00:00 2026-05-30T04:11:39+00:00

I have a relatively simple problem bat as yet I haven found the most

  • 0

I have a relatively simple problem bat as yet I haven found the most appropriate solution.

I have a form which passes several user-selectable values as Get variables. Most of these are BooleanChoice fields and can be selected or not. What I want is a concise way of collecting all the GET keys in a list if the are not empty, and map them to more human readable forms for table headings.

For example if my get variables look like:

?site=1&&startdate=1988-09-09&enddate=1989-09-09&mean_air_temp=True&q=table&submit=Query

I want to make a list like so:

['site', 'startdate', 'endate', 'man_air_temp', ...,]

And then end up with:

['Site Name', 'Start Date', 'End Date', 'Mean Air Temp', ...,]

Which can then be associated with my data as table headings in the template.

I know there are various ways of doing this at length but would like to know if there is a concise, pythonic way of getting the results I want.

Any help much appreciated.

  • 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-30T04:11:40+00:00Added an answer on May 30, 2026 at 4:11 am

    GET parameters are supplied to the view as a dictionary-like object in request.GET. So, you just need another dictionary to map the keys to your desired headings:

    header_mapping = {
        'site': 'Site Name',
        'startdate': 'Start Date'.
        ....
    }
    headers = [header_mapping[k] for k, v in request.GET.items() if v]
    

    The list comprehension simply maps through the list of (key, value) pairs in the GET querydict, and if the value is not empty it looks up the header mapping and adds it to a list.

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

Sidebar

Related Questions

I have a relatively simple form which asks a variety of questions. One of
I have a relatively simple problem. I have a model named Item which I've
I have a relatively simple application which I need to make native Mac OSX
I have a problem with a relatively simple query and the execution plan Access
So, my problem is relatively simple. I have one spider crawling multiple sites, and
A relatively simple question. I have a datagridview, which all it does is displays
I have a set of classes and interfaces which have a relatively simple hierarchy,
So my problem is relatively simple, I've Googled all over to find a solution
I have a computational geometry problem that I feel should have a relatively simple
I have a relatively simple site that I'm working up for an intranet environment.

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.