EmilStenstrom / django-components

Create simple reusable template components in Django.
MIT License
953 stars 59 forks source link

template_loader blocks on STATICFILES_DIRS if there are tuples #476

Closed alexandreMartinEcl closed 1 week ago

alexandreMartinEcl commented 2 weeks ago

How to reproduce

Simply run django with, in your settings.py, something like :

STATICFILES_DIRS = [
    # ...
    ("downloads", "/opt/webfiles/stats"),
]

(as made possible natively in Django)

Current behaviour

Getting TypeError: expected str, bytes or os.PathLike object, not tuple given [this line] (https://github.com/EmilStenstrom/django-components/blob/e566d8ecbb7016cf3a8861a47a4a52e4a503b838/src/django_components/template_loader.py#L49)

Expected

class Loader from _src/django_components/templateloader.py should consider the second item of STATICFILES_DIRS list item when not a str.

Furthermore

Thank you a lot, sir, for this django library. It helped us, a French news company, a lot to center our codebase almost fully on Django. I might try to suggest a clean PR for this

EmilStenstrom commented 2 weeks ago

@alexandreMartinEcl Happy to hear that your are getting more use from Django based off this library! Makes my developer heart beat a little faster <3

As for the suggestion, I think this is something we should fix. If you could write up a PR, with a corresponding test, we can add that to the library!