Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid filter: __pyjade_iter (Django) #205

Closed
gummz opened this issue Aug 22, 2015 · 3 comments
Closed

Invalid filter: __pyjade_iter (Django) #205

gummz opened this issue Aug 22, 2015 · 3 comments

Comments

@gummz
Copy link

gummz commented Aug 22, 2015

I'm probably doing something wrong here but:

for story in stories
    #{story.title}

where stories=Stories.objects.all(), (exactly one entry is in the database) returns:

TRACEBACK:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/stories/

Django Version: 1.8.3
Python Version: 2.7.0
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'account',
 'disqus',
 'crispy_forms',
 'crispy_forms_foundation',
 'index',
 'comments',
 'user_profile',
 'story')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'account.middleware.LocaleMiddleware',
 'account.middleware.TimezoneMiddleware')


Template error:
In template D:\development\PyCharm\Projects\fcon\story\templates\story_list.html, error at line 3
   Invalid filter: '__pyjade_iter'

   1 : {% extends "base.html" %}{% block title %}



   2 : <title>Story List</title>{% endblock %}{% block content %}



   3 : <ul> {% for story in stories|__pyjade_iter:1 %} 



   4 :   <li>{{story.title|escape}}</li>{% endfor %}



   5 : </ul>{% endblock %}

Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "D:/development/PyCharm/Projects/fcon\story\views.py" in story_list
  13.                   dict(stories=Story.objects.all()),
File "C:\Python27\lib\site-packages\django\shortcuts.py" in render
  67.             template_name, context, request=request, using=using)
File "C:\Python27\lib\site-packages\django\template\loader.py" in render_to_string
  98.             template = get_template(template_name, using=using)
File "C:\Python27\lib\site-packages\django\template\loader.py" in get_template
  35.                 return engine.get_template(template_name, dirs)
File "C:\Python27\lib\site-packages\django\template\backends\django.py" in get_template
  30.         return Template(self.engine.get_template(template_name, dirs))
File "C:\Python27\lib\site-packages\django\template\engine.py" in get_template
  167.         template, origin = self.find_template(template_name, dirs)
File "C:\Python27\lib\site-packages\django\template\engine.py" in find_template
  141.                 source, display_name = loader(name, dirs)
File "C:\Python27\lib\site-packages\django\template\loaders\base.py" in __call__
  13.         return self.load_template(template_name, template_dirs)
File "C:\Python27\lib\site-packages\django\template\loaders\base.py" in load_template
  23.             template = Template(source, origin, template_name, self.engine)
File "C:\Python27\lib\site-packages\django\template\base.py" in __init__
  190.         self.nodelist = engine.compile_string(template_string, origin)
File "C:\Python27\lib\site-packages\django\template\engine.py" in compile_string
  261.         return parser.parse()
File "C:\Python27\lib\site-packages\django\template\base.py" in parse
  341.                     compiled_result = compile_func(self, token)
File "C:\Python27\lib\site-packages\django\template\loader_tags.py" in do_extends
  210.     nodelist = parser.parse()
File "C:\Python27\lib\site-packages\django\template\base.py" in parse
  341.                     compiled_result = compile_func(self, token)
File "C:\Python27\lib\site-packages\django\template\loader_tags.py" in do_block
  184.     nodelist = parser.parse(('endblock',))
File "C:\Python27\lib\site-packages\django\template\base.py" in parse
  341.                     compiled_result = compile_func(self, token)
File "C:\Python27\lib\site-packages\django\template\defaulttags.py" in do_for
  871.     sequence = parser.compile_filter(bits[in_index + 1])
File "C:\Python27\lib\site-packages\django\template\base.py" in compile_filter
  423.         return FilterExpression(token, self)
File "C:\Python27\lib\site-packages\django\template\base.py" in __init__
  633.                 filter_func = parser.find_filter(filter_name)
File "C:\Python27\lib\site-packages\django\template\base.py" in find_filter
  429.             raise TemplateSyntaxError("Invalid filter: '%s'" % filter_name)

Exception Type: TemplateSyntaxError at /stories/
Exception Value: Invalid filter: '__pyjade_iter'

@blx
Copy link
Contributor

blx commented Aug 22, 2015

Hmm, I'm not tooo sure what's going on, but just to double check:

Do you have PyJade set up as a template backend in your settings.py? (as in this link)

The __pyjade_iter filter gets defined by pyjade in the django extension, so perhaps it's not getting setup somehow?

Edit: it looks like you're loading a django-style template (.html) already - did you pre-render all of your jade templates? If so then you might have to copy the code from pyjade.runtime.iteration() and add it as a django filter.

@gummz
Copy link
Author

gummz commented Aug 22, 2015

That was indeed the problem, thank you very much!

I had the pyjade backend in TEMPLATE_LOADERS instead of 'loaders.' I also had to set app_dirs to false.

Have a nice day!

@gummz gummz closed this as completed Aug 22, 2015
@blx
Copy link
Contributor

blx commented Aug 23, 2015

Great!

I opened a pull request to update the readme instructions for Django 1.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants