#28428: Add support for Pathlib objects in django.core.storage -----------------------------------------+------------------------ Reporter: Tom | Owner: nobody Type: New feature | Status: new Component: Uncategorized | Version: master Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -----------------------------------------+------------------------ Code in django.core.storage will explode when given a Pathlib object on Python 3.4 and 3.5. For example, this throws a cryptic `AttributeError: 'PosixPath' object has no attribute 'rfind'` exception due to `generate_filename` only expecting strings:
{{{ def upload_to(filename): return pathlib.Path(filename) class Storage(models.Model): file = models.FileField(upload_to=upload_to) }}} More generally, it would be nice if all methods in the django.core.files accepted pathlib objects, and used pathlib objects internally. For compatibility reasons I think strings would have to be returned. -- Ticket URL: <https://code.djangoproject.com/ticket/28428> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/046.81544b01bc8631b227f16fa3cd6bde57%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.