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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:00:48+00:00 2026-05-17T16:00:48+00:00

In a Django view you can access the request.GET[‘variablename’] , so in your view

  • 0

In a Django view you can access the request.GET['variablename'], so in your view you can do something like this:

myvar = request.GET['myvar']

The actual request.GET['myvar'] object type is:

<class 'django.http.QueryDict'>

Now, if you want to pass multiple variables with the same parameter name, i.e:

http://example.com/blah/?myvar=123&myvar=567

You would like a python list returned for the parameter myvar, then do something like this:

for var in request.GET['myvar']:
    print(var)

However, when you try that you only get the last value passed in the url i.e in the example above you will get 567, and the result in the shell will be:

5
6
7

However, when you do a print of request.GET it seems like it has a list i.e:

<QueryDict: {u'myvar': [u'123', u'567']}>

Ok Update:
It’s designed to return the last value, my use case is i need a list.

from django docs:

QueryDict.getitem(key)
Returns
the value for the given key. If the
key has more than one value,
getitem() returns the last value. Raises
django.utils.datastructures.MultiValueDictKeyError
if the key does not exist. (This is a
subclass of Python’s standard
KeyError, so you can stick to catching
KeyError

QueryDict.getlist(key) Returns the
data with the requested key, as a
Python list. Returns an empty list if
the key doesn’t exist. It’s guaranteed
to return a list of some sort.

Update:
If anyone knows why django dev’s have done this please let me know, seems counter-intuitive to show a list and it does not behave like one. Not very pythonic!

  • 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-17T16:00:49+00:00Added an answer on May 17, 2026 at 4:00 pm

    You want the getlist() function of the GET object:

    request.GET.getlist('myvar')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am sending an AJAX request to a Django view that can potentially take
Usually in a django view you would do something like queryset = MyModel.objects.something() How
I would like to be able to access request object in django admins clean()
I tried to submit this form using ajax ,sothat a django view can extract
I have 2 forms in my Django view. How can I do a check
How can I increase django execution time of a view. Some views of my
I have a Django project. Given a url, how can I know which view
I am trying to specify the access to a certain django view only to
Django view points to a function, which can be a problem if you want
My django view goes through a list , uses regex to detect specific elements

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.