django doesn't support pathlib
hiaselhans opened this issue · 5 comments
as I discovered recently in django/django#15835 Django does NOT officially support pathlib for template paths.
So i suggest to revert the following commit in the meantime:
7d0b661
and Django is not going to support pathlib.Path in the near future:
ticket-33839
But the Django source code is full of import pathlib
statements. Moreover, all paths specified in settings.py, such as MEDIA_ROOT
, STATIC_ROOT
, etc. can and shall be of type pathlib.Path
, so I really do not understand what you mean with
and Django is not going to support pathlib.Path in the near future:
Hi @jrief
did you read the referenced issue?
Jinja backend is unable to handle pathlib and the relevant ticket got rejected with the justification that django template is NOT going to support pathlib.
Django template backend can also be not filesystem based.
Please either reopen the issue or join the discussion on django.
@hiaselhans does this mean that django-admin-sortable2 currently does not work with Jinja2 templates?
But this then leads to another question: Who is using Jinja2 templates in the Django admin?
It means that django-admin-sortable2 does not run when using any other additional template engine that doesn't handle posixpath.
nobody is using Jinja for Django admin, but Django template resolution tries the filename with all template engines.
def get_template(template_name, using=None):
"""
Load and return a template for the given name.
Raise TemplateDoesNotExist if no such template exists.
"""
chain = []
engines = _engine_list(using)
for engine in engines:
try:
return engine.get_template(template_name)
except TemplateDoesNotExist as e:
chain.append(e)
raise TemplateDoesNotExist(template_name, chain=chain)
AttributeError("'PosixPath' object has no attribute 'split'") is not catched and thus rendering fails because template resolution order isn't continued.