[Fixed]-How to store URL parameters in GET requests in django?

1๐Ÿ‘

โœ…

why do you need POST request?
Just implement the GET request using simple get() โ€“ class view of function.

You can just use check query request.GET directly, or if you want to use form, you can just instantiate it with the request.GET as the parameter, but IMHO, there is no real reason for this.

You can just do something like this:

class TrackView(View):
    def get(self, request):
        try:
            track,_ = Track.objects.get_or_create(domain = request.GET['domain'])
            track.url_name = request.GET['url']
            track.title = request.GET['title']
            track.ip = request.GET['ip']
            track.referrer = request.GET['referrer']
            track.save()
            return HttpResponse(status=200) 
        except KeyError:
            return HttpResponse(status=400)
๐Ÿ‘คeran

Leave a comment