我正在尝试使用 Django Rest Framework 制作 APIView。当我将视图与 url 相关联时,出现此错误:
AssertionError: basename argument not specified, and could not automatically determine the name from the viewset, as it does not have a .queryset attribute.
这是我的 APIView :
class ExampleView(APIView):
authentication_classes = (SessionAuthentication, BasicAuthentication)
permission_classes = (IsAuthenticated,)
def get(self, request, format=None):
content = {
'user': unicode(request.user), # `django.contrib.auth.User` instance.
'auth': unicode(request.auth), # None
}
return Response(content)
Run Code Online (Sandbox Code Playgroud)
和路由器:
router = routers.DefaultRouter()
router.register('api/example', views.ExampleView.as_view())
Run Code Online (Sandbox Code Playgroud)
那么,怎么了?谢谢 !
出现此错误:(SystemJS)模块'DossierModule'导入的意外值'undefined'
我有2个ngModules相互导入,这个错误可能来自那个吗?在那种情况下:DossierModule导入ContactModule,而ContactModule导入DossierModule.当我在ContactModule中删除导入时,它的工作原理与DossierModule相同.
那2个模块不能互相导入?
谢谢.
我有一个带布尔参数的函数,但它也可以为null.
如果是真或假,则使用"WHERE"子句进行查询.如果为null,则查询没有"WHERE"子句,只有select子句.
我怎么能用Java做到这一点?