Skip to content

QueryString encode issue with small fix  #2077

@ebertti

Description

@ebertti

When the url has some querystring like:

http://domain.com/path/to/view/?query=some%40mail.com

django wait to receive this:

def some_view(request): query = request.GET.get('query') assert query == 'some@mail.com'

with Zappa 0.51.0 and Django 3.0.5 and python 3.7 on Lambda and ALB

this is the actual behavior

def some_view(request): query = request.GET.get('query') assert query == 'some%40mail.com'

So I made this small middleware to quick fix:

class FixQueryStringZappaMiddleware: def __init__(self, get_response): self.get_response = get_response def __call__(self, request): if os.envirion('FRAMEWORK') == 'Zappa': querystring = request.GET.urlencode() u = urllib.parse.unquote(querystring) request.GET = QueryDict(u) response = self.get_response(request) return response

and add this middleware as first of your list of middlewares

this is my zappa_settings.json

{ "project": { "project_name": "project-backend", "aws_region": "sa-east-1", "alb_enabled": true, "apigateway_enabled": false, "cors": true, "keep_warm": false, "touch": false, "runtime": "python3.7", "timeout_seconds": 900, "log_level": "INFO", "s3_bucket": "some-bucket", "delete_s3_zip": false, "debug": true } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions