django_markdown icon indicating copy to clipboard operation
django_markdown copied to clipboard

Internal Server Error on preview

Open iLikeKoffee opened this issue 9 years ago • 3 comments

Hello, I tried to install this library on Django 1.9 and got such error in admin interface when tried to run preview.

Internal Server Error: /markdown/preview/
Traceback (most recent call last):
  File "/home/alexey/Dev/profcom/django-rest-env/lib/python3.4/site-packages/django/core/handlers/base.py", line 149, in get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/alexey/Dev/profcom/django-rest-env/lib/python3.4/site-packages/django/core/handlers/base.py", line 147, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/alexey/Dev/profcom/django-rest-env/lib/python3.4/site-packages/django_markdown/views.py", line 22, in preview
    content=request.REQUEST.get('data', 'No content posted'),
AttributeError: 'WSGIRequest' object has no attribute 'REQUEST'
[10/Dec/2015 22:14:47] "POST /markdown/preview/ HTTP/1.1" 500 14951

Here is the model code

class Post(models.Model):
    name = models.CharField(max_length=50, null=False, primary_key=True)  # Name for human-readable url
    title = models.CharField(max_length=255, null=False, unique=True)  # Human-readable title
    text = MarkdownField()  # Text in markdown syntax
    documents = models.ManyToManyField('Document', blank=True)
    commission = models.ForeignKey('Commission', related_name="posts")
    pinned = models.BooleanField(default=False)  # Should display on main
    date = models.DateTimeField(auto_now=True)
    image = models.FileField(upload_to='post_tiles', null=True)

Is it compatible with django 1.9? Thank you in advance!

Sinclerely, Alexey


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

iLikeKoffee avatar Dec 10 '15 22:12 iLikeKoffee

I am facing the same issue.

noisytoken avatar Jan 04 '16 05:01 noisytoken

Someone opened a PR (#60) about this. Until it is not merged just alter your views.py of django_markdown. Worked for me perfectly.

macskay avatar Jan 23 '16 22:01 macskay

request.REQUEST was deprecated in Django 1.7, and removed in Django 1.9.

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

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

to

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

jarifibrahim avatar Jan 26 '16 18:01 jarifibrahim