Markdown is optional but my project already has Markdown 2.6 installed, get prepocessor error.

18 views
Skip to first unread message

Courtney Bracefield

unread,
Sep 17, 2019, 5:42:18 PM9/17/19
to Django REST framework
Hi there,

I have Markdown 2.6 installed on my project and it is not feasible to update to version 3.0+ at this time.

Thus in compat.py it successfully imports Markdown, however it breaks on line 213 because the highlight markdown preprocessor now uses register instead of add. 

The error is:

Exception Type: AttributeError
Exception Value: 'OrderedDict' object has no attribute 'register'

Exception Location: /docker_venv/lib/python3.6/site-packages/rest_framework/compat.py in md_filter_add_syntax_highlight, line 213


How can I get around this?

Relevant issues/PRs I found:
https://github.com/encode/django-rest-framework/pull/6722
https://github.com/encode/django-rest-framework/pull/6412

Thanks!

Ryan Kilby

unread,
Sep 18, 2019, 4:43:29 PM9/18/19
to Django REST framework
The compat code is executed at import time, so there's no trivial way to override this. If you can't upgrade Markdown, then you'll need to downgrade to DRF 3.9.x

Out of curiosity, what's preventing you from upgrading to Markdown 3.x?

Courtney Bracefield

unread,
Sep 18, 2019, 5:10:28 PM9/18/19
to Django REST framework
Thanks for the reply! I ended up forking the DRF repo and commenting out the lines causing me trouble...

As for the prevention of upgrading, I don't entirely understand it myself but my boss has said that it would be a few months working changing over to Markdown 3.

We have built an extension of the markdown package that a lot of our projects rely on: https://verto.readthedocs.io/en/latest/ I believe this is why it's a hassle to upgrade right now.

I'm stuck on a new problem now with serializing and abstract classes.... :(
Reply all
Reply to author
Forward
0 new messages