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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:48:34+00:00 2026-06-04T09:48:34+00:00

I try to translate a code i use in my templates and js to

  • 0

I try to translate a code i use in my templates and js to a content_type and object_id that is being used by the wrapped function:

def translate_modelcode(function=None,redirect_field_name=None):
    """
    translate an item-code specified in settings to a content_type
    and the item-id to the object_id
    """

    def _decorator(function):
        def _wrapped_view(request, *args, **kwargs):

            item_code=request.REQUEST.get('item-code',None)
            if item_code:
                object_id = request.REQUEST.get('item-id',None)
                # resolve_modelcode get's the models name from settings
                content_type = resolve_modelcode(item_code)
                ud_dict = {'content_type':content_type,
                          'object_id':object_id}
                if request.method == 'GET':
                    request.GET.update(ud_dict)
                else:
                    request.POST.update(ud_dict)


            return function(request, *args, **kwargs)
        return _wrapped_view

    if function is None:
        return _decorator
    else:
        return _decorator(function)

The point where i am stuck is the updating of the request.POST / request.GET QueryDict. Django reports those dicts as being immutable. How can i update them?

From the djangodocs i thought .update would use the “last-value logic” described there, which i would be perfectly fine with. But that’s not happening. Creating a copy and reassigning that to request.GET doesn’t seem to work either:

request.GET = request.GET.copy().update(ud_dict)

There is a somewhat similar question on this topic here on SO, but it never got a satisfying answer. Using the same code as in that question i just get a null return for request.POST or request.GET after updating:

request._get = request.GET.copy()
import ipdb;ipdb.set_trace()

ipdb> request.GET
ipdb> 

So what can i do about this?

  • 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-04T09:48:35+00:00Added an answer on June 4, 2026 at 9:48 am

    The update(...) method does not have a return value, it updates its instance in-place. So instead of request.GET = request.GET.copy().update(ud_dict) you should write

    request.GET = request.GET.copy()
    request.GET.update(ud_dict)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try tu use this msdn snipped to execute some code right after my
I'm using Google Translate API, and if I try to translate Mc Donald's this
I'm looking to translate words by letters/vowels. I'll try to explain. I have a
try: spam.foo except AttributeError: do_somthing() (Is it wise to check an attribute like that
Try the following code: s = '#value#' puts s.gsub('#value#', Regexp.escape('*')) # => '\*' puts
I'm trying to use code similar to clrdump to create mini dumps in my
I'm trying to write a UDF to translate a string that is either a
I am using Entity Framework 4.0 and trying to use the Contains function of
Below are 2 code snippets used to check if a folder exists in a
I want to translate my text into device language. So I tried below code

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.