class ArticleRevisionResource(ModelResource):
article_id = fields.IntegerField(attribute='article_id')
class Meta:
queryset = ArticleRevision.objects.all()
resource_name = 'articlerevision'
authentication = Authentication()
authorization = DjangoAuthorization()
allowed_methods = ['get', 'post', 'put', 'delete']
class ArticleResource(ModelResource):
#revision = fields.ForeignKey(ArticleRevisionResource, 'article')
class Meta:
queryset = Article.objects.all()
resource_name = 'article'
authentication = Authentication()
authorization = DjangoAuthorization()
allowed_methods = ['get', 'post', 'option', 'put']
fields = ['title', 'content', 'article_id']
def obj_create(self, bundle, request=None, **kwargs):
print("==========Obj_create method==========")
title, content = bundle.data['title'], bundle.data['content']
bundle.obj = ArticleRevision.objects.create(title="lala", content="lulu", article_id=40)
bundle.obj.save()
return bundle
所以问题是它没有打印出Obj_create
方法,但是如果我将相同的调试打印元素放入Meta class
,它会打印出来。那么我该怎么做才能找出obj_create
方法不起作用的原因呢?