I have a file with my custom jinja2 filters. These work fine when pasted directly into pelicanconf.py. However, when I attempt to import the module using
import jinja_custom_filters as jcf
I get the following error:
ModuleNotFoundError: No module named 'jinja_custom_filters'
I wrote a quick test file in the same directory as pelicanconf.py and jinja_custom_filters.py, and it has no problem importing jinja_custom_filters.
I've combed the documentation, but I can't find anything that would assist with this.
is jinja_custom_filters.py in your pythonpath?
whats the general layout of your setup, i.e. where is pelicanconf.py and where is your filter module?
It work for me
import sys
sys.path.append('.')
import jinja_custom_filters
JINJA_FILTERS = {'filter_name_in_html': jinja_custom_filters.the_filter_function}
and It work fine for me, maybe need to update the Docs?
Answer From
Works for me as well. I have the problem on Windows with vritual env. Is this something to do with pelican running in a different home directory.
eg a pelicanconf.py file like this:
import sys
sys.path.append('.')
from base import *
Closing due to inactivity. Please feel free to comment here if you feel the issue should be re-opened.
Well, it's still broken, so maybe it should be re-opened on that basis.
@deutrino: Not a very helpful comment. Most of what I’m seeing here is “works for me.” Moreover, the word “broken” is about the most information-free word imaginable in a software context.
this workaround works, but feels more like unnecessary step and strange behavior
in my opinion import should work directly, without adding '.' to path
so the issue is that pelican don't import modules located in the same directory as pelicanconf.py
it would be nice if it could do so