#9586: Shall upload_to return an urlencoded string or not?
--------------------------------------+------------------------------------
     Reporter:  eibaan                |                    Owner:
         Type:  Bug                   |                   Status:  new
    Component:  File uploads/storage  |                  Version:  1.0
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  1                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Changes (by sergei-maertens):

 * needs_better_patch:  1 => 0
 * needs_tests:  1 => 0


Comment:

 Looks like this was fixed by #25905 - I cannot reproduce the original
 issue. I haven't tested on Windows though.

 `models.py`:

 {{{
 #!python
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals

 from django.db import models


 def upload_to(instance, filename):
     return 'Großköln / €/{}'.format(filename)


 class FileModel(models.Model):
     file = models.FileField(upload_to=upload_to)

 }}}

 `admin.py`
 {{{
 #!python
 from django.contrib import admin

 from .models import FileModel


 admin.site.register(FileModel)
 }}}

 and the rest is the standard media/staticfiles settings/urls.

 The url presented to me in the admin:

 `<a href="/media/Gro%C3%9Fk%C3%B6ln%20/%20%E2%82%AC/mail.txt">Großköln /
 €/mail.txt</a>`

 which is properly escaped and served by django.

--
Ticket URL: <https://code.djangoproject.com/ticket/9586#comment:13>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.33afa5c7adb3d6316522a77dc10edb2c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to