开发者

"CSRF verification failed" when attempting to upload a file or create a folder with filebrowser for Django

I have installed filebrowser for Django (not filebrowser3) and when I try to upload a file I recieve the following e开发者_如何学编程rror:

403 Forbidden

CSRF verification failed. Request aborted.

More information is available with DEBUG=True.

The same error occurs when I try to create a new folder which shows that the problem is that filebrowser cannot create files/direcories within my uploads directory. I am using the default settings and have manually created the /media/uploads directory with it's permissions set as 755.

If I upload a file to the directory then file-browser admin page states:

1 Item Folder: 0 Image: 1

I cannot view the image that I have uploaded.

I have the PIL and sorl.thumbnail modules installed.


You are probably using the development version of Django, which includes quite a lot of extra CRSF security. However it's not released yet so external products probably aren't compatible. You should use the 1.1 version of Django instead.


The Djangodocs have more information about the new Django CSRF requirements:


Add to you settings.py this 2 lines:

‘django.middleware.csrf.CsrfViewMiddleware’, ‘django.middleware.csrf.CsrfResponseMiddleware’,


See here: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/ like fitzgeralsteele said. Hugs.

Example: from django.views.decorators.csrf import csrf_exempt

@csrf_exempt def my_view(request): return HttpResponse(‘Hello world’)

Disable the CSRF middleware.


it work adding

{% csrf_token %} 

my forms looks like this:

<form method="post" action="">
{% csrf_token %}
{{ form.non_field_errors }}
{{formulario}}
<input type="submit" value="Guardar">
</form>

in to the tags on your template file and verify that 'django.middleware.csrf.CsrfViewMiddleware', is in your settings file, it is in by default

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜