stephenmcd / mezzanine

CMS framework for Django
http://mezzanine.jupo.org
BSD 2-Clause "Simplified" License
4.76k stars 1.65k forks source link

Django 3 - "ifinstalled" filter not working #1972

Closed rantecki closed 3 years ago

rantecki commented 3 years ago

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 commented 3 years ago

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

jerivas commented 3 years ago

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

github-actions[bot] commented 3 years ago

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

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 5.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: