2

https://django-tastypie.readthedocs.org/en/latest/authentication_authorization.htmlによると、セッション認証をオンにしている場合、 csrf が必要です。一時的にオフにするにはどうすればよいですか? https://django-tastypie.readthedocs.org/en/latest/cookbook.html?highlight=csrf#determining-format-via-urlのようなものが表示 されます@csrf_exempt を持っています。Google からは何も返されませんでした。

4

2 に答える 2

2

私は同じ問題を抱えていましたが、メソッド SessionAutentication をオーバーライドして解決しました。

于 2013-02-05T10:07:09.053 に答える
0

@UnLiMiTeD が言ったように、Authentication のサブクラスを作成して機能させました。

from tastypie.resources import ModelResource
from tastypie.authentication import Authentication

class BaseAuthentication(Authentication):

    def is_authenticated(self, request, **kwargs):
        return request.user.is_authenticated()

class YourResource(ModelResource):
    class Meta:
        authentication = BaseAuthentication()
于 2015-01-05T08:44:43.773 に答える