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

Django 3 - "ifinstalled" filter not working #1972

Closed
rantecki opened this issue Nov 10, 2020 · 4 comments
Closed

Django 3 - "ifinstalled" filter not working #1972

rantecki opened this issue Nov 10, 2020 · 4 comments

Comments

@rantecki
Copy link

I'm trying out the latest master on Django 3.1. I understand that this doesn't appear to be officially supported yet, but I noticed support had been enabled in the latest HEAD, so I thought I'd give it a go.

I ran into a strange issue with the ifinstalled template tag - it doesn't seem to work at all and tries to include the contents regardless of whether the app is installed.

After some investigation, I narrowed this down to the following in the definition of the isinstalled tag (in core/templatetags/mezzanine_tags.py):

        while unmatched_end_tag:
            token = parser.tokens.pop(0)

It appears this is processing the nodes in the wrong order (last token first). It looks like parser.tokens returns the nodes in reverse order. I can only presume this is a new change in Django 3, but I haven't done any deep investigation into this.

A simple and obvious fix for this appears to be:

        while unmatched_end_tag:
            token = parser.tokens.pop()

However, I imagine this would break Django < 3, so you would probably need to add some conditions around this.

Anyway, hopefully this provides enough groundwork for someone more familiar with the project/codebase to take it from here.

dbischof added a commit to CompostNow/mezzanine that referenced this issue Feb 1, 2021
@dbischof
Copy link
Contributor

dbischof commented Feb 2, 2021

Since the order seems to be reversed I had had to replace
parser.tokens.insert(0, token)
with
parser.tokens.append(token)

@jerivas
Copy link
Collaborator

jerivas commented Jun 1, 2021

This is currently one of the problems causing test failures and preventing a new release. Contributions are welcome!

@jerivas jerivas added this to To do in Mezzanine 5 Jul 19, 2021
Mezzanine 5 automation moved this from To do to Done Jul 21, 2021
@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 5.0.0-rc.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 5.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Mezzanine 5
  
Done
Development

No branches or pull requests

3 participants