M. Mariscal
M. Mariscal

Reputation: 1328

How to get decoded url to download a file on Django?

URL='http://localhost:8765/app/download/?file=/path/to/download/my%3Afolder/file_signed_django.xml'

I'd like to know how to deal with this URL, i'm trying to download this file (Signed by Django), the problem is when it changes ':' to '%3A', don't know how to get rid of it, i'm using Django 1.9.13

Thank you so much

Upvotes: 0

Views: 56

Answers (2)

M. Mariscal
M. Mariscal

Reputation: 1328

FINALLY, I did some changes at the model (Because I cannot deal with it on views.py, cause it's signed and definitely cannot be changed). Let me show you my code:

@staticmethod
def fix_path(path):
    if ':' in path:
        return path.replace(':','')
    return path

That's what i've added on my class, you can do whatever, but only at the modal

Upvotes: 0

Pankaj Sharma
Pankaj Sharma

Reputation: 2267

Use urllib.unquote to decode %- urllib.unquote(url)

Try this and comment, wheather it works for you.

Upvotes: 1

Related Questions