You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If you start out with Sanic and install sanic[ext], then try to use templating before installing Jinja2, you get a confusing error which may make you think that Sanic itself is broken.
I had a fairly trivial example, for a template using a request parameter
(irrelevant lines removed)
This was in server.py. Trying to run it without Jinja installed yielded:
$ sanic server:app
Traceback (most recent call last):
File "/home/shai/.virtualenvs/sanic3.10/bin/sanic", line 8, in <module>
sys.exit(main())
File "/home/shai/.virtualenvs/sanic3.10/lib/python3.10/site-packages/sanic/__main__.py", line 12, in main
cli.run(args)
File "/home/shai/.virtualenvs/sanic3.10/lib/python3.10/site-packages/sanic/cli/app.py", line 106, in run
app = self._get_app(app_loader)
File "/home/shai/.virtualenvs/sanic3.10/lib/python3.10/site-packages/sanic/cli/app.py", line 175, in _get_app
app = app_loader.load()
File "/home/shai/.virtualenvs/sanic3.10/lib/python3.10/site-packages/sanic/worker/loader.py", line 78, in load
module = import_module(self.module_name)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/shai/sanic/server.py", line 13, in <module>
@app.ext.template("room.html")
File "/home/shai/.virtualenvs/sanic3.10/lib/python3.10/site-packages/sanic_ext/bootstrap.py", line 210, in template
return self.templating.template(template_name, **kwargs)
AttributeError: 'Extend' object has no attribute 'templating'. Did you mean: 'template'?
Expected behavior
I'd expect an error saying something like "you need a templating library installed". Something to make it clear that it's me doing something wrong, not the framework.
Environment (please complete the following information):
OS: Debian testing (currently trixie)
Version 23.3.0
The text was updated successfully, but these errors were encountered:
Describe the bug
If you start out with Sanic and install
sanic[ext]
, then try to use templating before installing Jinja2, you get a confusing error which may make you think that Sanic itself is broken.I had a fairly trivial example, for a template using a request parameter
(irrelevant lines removed)
This was in
server.py
. Trying to run it without Jinja installed yielded:Expected behavior
I'd expect an error saying something like "you need a templating library installed". Something to make it clear that it's me doing something wrong, not the framework.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: