How can I delete GET url parameter after creating array in django?

Django Learner

I am working django and I want to fetch GET requests from url and want to delete couple of parameter and than save rest of in database as list.

For example, requested url is

localhost/test?a=A&b=B&c=C&d=D&e=E

I know how to get GET parameters in json format by simply doing

json.dumps(reqest.GET)

and when I print it out in template HttpResponse, I get

{"a":"A", "b":"B", "c":"C", "d":"D", "e":"E"}

what I want to do is I want to remove couple elements from it and create json. I want to remove by key "a" and "d". So my json should look like,

{"b":"B", "c":"C", "e":"E"}

Can anyone tell me how can I do it? I tried to look for list, json to list etc and remove(), del element etc method. Each time I was getting errors so can anyone help me?

Thank you for your time.

viral4ever

You can try something like this,

a = json.loads(json.dumps(request.GET))

        del a['a']
        del a['d']

return HttpResponse(json.dumps(a), content_type="application/json")

Let me know if helps... :D ;)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I get Argumants that start with specific parameter in URL Django?

How can I get a URL parameter with jQuery?

How can i get url parameter in laravel?

How can I insert a variable into the resulting url parameter string after submitting my GET form?

How can I get the URL parameter after the domain name in php/apache configuration?

How can I get the url of a Django ImageField?

How can I get time efficent by creating an array with for loop?

How can i get my url parameter right on Javascript?

How can I get a full url as parameter in a route

How can I get an Array of Objects after iterating array of strings?

How can I get the full url including characters after a # char

How can I get Django Absolute url without "www" in domain?

How can I get the URL (with protocol and domain) in Django (without request)?

How can I get {% url logout %} to work in my Django template?

How can I get the full/absolute URL (with domain) in Django?

How can i get a url param for an updateview in django?

Delete from Many to many. How can I remember parameter from URL?

how can i get an array after match query in mongodb aggregation

How can I get the array size after all timeout be executed

How can I get the new array after unset?

How can I get my parameter object AFTER my method has modified the parameter?

How can I delete a message after sending it?

How to get URL array parameter in javascript

How can I delete the URL history in TortoiseGit?

How can I get rid of additional files to commit after creating a virtual environment in VS Code?

How can i delete database table in django?

Django template add GET parameter after current URL

How can I use __chooseRandom with a URL parameter?

How can I replace the value of a URL parameter?

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    flutter: dropdown item programmatically unselect problem

  14. 14

    How to use merge windows unallocated space into Ubuntu using GParted?

  15. 15

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  16. 16

    Nuget add packages gives access denied errors

  17. 17

    Svchost high CPU from Microsoft.BingWeather app errors

  18. 18

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  19. 19

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  20. 20

    Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive