Cody Cody - 2 months ago 15
Markdown Question

django_markdown failed to show preview in django 1.9

In trying to integrate

django_markdown
in django admin panel. After creating a post when preview button is clicked it shows the following error in console.

Here is the traceback:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/markdown/preview/

Django Version: 1.9
Python Version: 3.4.3
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
'ckeditor',
'django_markdown']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'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']



Traceback:

File "C:\Users\X\test_django\lib\site-packages\django\core\handlers\base.py" in get_response
149. response = self.process_exception_by_middleware(e, request)

File "C:\Users\X\test_django\lib\site-packages\django\core\handlers\base.py" in get_response
147. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "C:\Users\X\test_django\lib\site-packages\django_markdown\views.py" in preview
22. content=request.REQUEST.get('data', 'No content posted'),

Exception Type: AttributeError at /markdown/preview/
Exception Value: 'WSGIRequest' object has no attribute 'REQUEST'


Please guide me how to correct it.

Answer

Here is the workaround

Open views.py inside folder django_markdown.

Open the file views.py and go to line 22, and change the following line

content=request.REQUEST.get('data', 'No content posted'),

to this

content=request.POST.get('data', 'No content posted'),