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

TypeError : 'QueryDict' object is not callable on markdown preview #50

Open
DarkRedman opened this issue Aug 30, 2015 · 2 comments
Open

Comments

@DarkRedman
Copy link

DarkRedman commented Aug 30, 2015

When I try to preview my markdown I got an error 500 with this response.

`Environment:

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

Django Version: 1.8.4
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',
'django_markdown')
Installed Middleware:
('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',
'django.middleware.security.SecurityMiddleware')

Traceback:
File "/usr/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response

  1.                 response = wrapped_callback(request, _callback_args, *_callback_kwargs)
    
    File "/usr/lib/python3.4/site-packages/django_markdown/views.py" in preview
  2.         content=request.REQUEST.get('data','No posted content'),
    

Exception Type: TypeError at /markdown/preview/
Exception Value: 'QueryDict' object is not callable`

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/26309679-typeerror-querydict-object-is-not-callable-on-markdown-preview?utm_campaign=plugin&utm_content=tracker%2F332251&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F332251&utm_medium=issues&utm_source=github).
@Twiinner
Copy link

Twiinner commented Sep 9, 2020

Fix the views.py inside django_markdown folder at line 20:

return render(request,
 settings.MARKDOWN_PREVIEW_TEMPLATE,
 dict(content=request.GET.get('data', '## No content posted ##'),
 css=settings.MARKDOWN_STYLE
))

This problem was caused by an outdated method:

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

In django v3.1, there is no REQUEST.get, use this instead request.GET.get.
Furthermore, request.GET returns dictionary like object that alike QuerryDict

Please point out if I mistook something, any advice would be greatly appreciated !

@dapoadedire
Copy link

@Twiinner , thank you. This tutorial I'm watching is old and the guy is using an older version of django.
Your answer saved me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants