Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I satisfy a django.contrib.markup.templatetags.markup import restructuredtext in django 1.6?

Wondering which restructured package most of you use in django 1.5+?

from django.contrib.markup.templatetags.markup import restructuredtext

Returns:

ImportError ...
No module named markup.templatetags.markup

https://docs.djangoproject.com/en/1.6/releases/1.5-alpha-1/#django-utils-markup

like image 306
user1645914 Avatar asked Mar 22 '23 14:03

user1645914


2 Answers

Yes the django.utils.markup was deprecated in 1.5 and removed in 1.6. The Python implementation of the reStructuredText markup lives in the docutils package. That is the implementation that Django <= 1.5 used.

The easiest way to install docutils is using pip:

pip install docutils

You can find the old django.utils.markup implementation in the 1.5.x branch on Djangos github repo:

https://github.com/django/django/blob/stable/1.5.x/django/contrib/markup/templatetags/markup.py#L76

like image 107
jbub Avatar answered Apr 27 '23 01:04

jbub


This is an addon to the answer by @jbub:

When you have an old Django application and you want to continue using markup, follow these steps:

  • Delete django.contrib.markup from INSTALLED_APPS (in the file settings.py
  • Add a directory templatetags to your application
  • Copy the file markup.py from https://github.com/django/django/blob/stable/1.5.x/django/contrib/markup/templatetags/markup.py#L76 to templatetags
  • touch a file __init__.py in the templatetags directoy
  • Start over your webserver and see it working again.

Note that this procedure keeps your old application working. However, the deprecation of django.contrib.markup came for a reason: There were security concerns over possible cross-site scripting attacks using markdown. You are on your own to deal with this problem.

like image 34
Sir Cornflakes Avatar answered Apr 27 '23 00:04

Sir Cornflakes