Django,TastyPie commit_on_success 错误

Django, TastyPie commit_on_success error

我正在尝试将 TastyPie 添加到我的 Django 项目以构建 RESTful API。我正在使用 Django 1.8.2。我正在关注 official tutorial。 我创建了一个资源:

# myapp/api.py
from tastypie.resources import ModelResource
from myapp.models import Entry


class RecipeResource(ModelResource):
    class Meta:
        queryset = Entry.objects.all()

# urls.py
from django.conf.urls import include, url
from django.contrib import admin
from myapp.api import RecipeResource

recipe_resource = RecipeResource()

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    url(r'^api/', include(recipe_resource.urls)),
]

我认为问题不在我的代码中,因为它几乎是教程中的复制和粘贴。执行导入时出现错误:

from myapp.api import RecipeResource

我是 Django 和 TastyPie 的新手。可能是 TastyPie 不适用于 Django 1.8.2?

错误:

  File "/Users/rafalsroka/Documents/Pthn/Recipes/recipes-backend/lib/python2.7/site-packages/tastypie/resources.py", line 1740, in <module>
    class BaseModelResource(Resource):
  File "/Users/rafalsroka/Documents/Pthn/Recipes/recipes-backend/lib/python2.7/site-packages/tastypie/resources.py", line 2210, in BaseModelResource
    @transaction.commit_on_success()
AttributeError: 'module' object has no attribute 'commit_on_success'

看起来TastyPie缺少Django 1.8.2的支持。 commit_on_success 已在此版本的 Django 中删除。

我想使用最新版本,所以我切换到 Django Rest Framework