小编Ksh*_*tij的帖子

我可以在angularJS中的$ routeProvider.when()中传递多个控制器吗?

我尝试在各种线程上搜索这个,但我不能最终理解这一点.

test.config(['$routeProvider', function($routeProvider){
$routeProvider
    .when('/',
        {
            controller:'SimpleController1',
            templateUrl: 'partials/1.html'
        })
    .when('/xyz',
        {
            controller:'SimpleController1, SimpleController2',
            templateUrl:'partials/2.html'
        })
    .otherwise({ redirectTo: '/'});
}]);
Run Code Online (Sandbox Code Playgroud)

我尝试了上面的代码片段,但它没有用.我可以这样做吗?如果是,那么我在这里做错了什么?

angularjs angularjs-routing

5
推荐指数
1
解决办法
2万
查看次数

自定义身份验证类作为 DEFAULT_AUTHENTICATION_CLASSES?

我正在尝试使用 django rest 框架创建一个自定义身份验证类(我已在views.py文件本身中定义它)作为我的 django 项目的默认身份验证类。虽然我不确定这是否可能,但能够做到这一点似乎是合乎逻辑的。

@authentication_classes我知道通过在视图中使用装饰器来解决这个问题。但一遍又一遍地重复同样的事情似乎不合逻辑。官方API GUIDE也没有提及。如果你们中有人遇到过这种情况并且知道解决方案,我希望能够得到澄清。

REST_FRAMEWORK = {
    .
    .
    DEFAULT_AUTHENTICATION_CLASSES: (
        'appname.views.CustomAuthentication',
    ),
    .
    .
}
Run Code Online (Sandbox Code Playgroud)

Could not import 'appname.views.CustomAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'. ImportError: cannot import name views.

谢谢

django django-rest-framework

5
推荐指数
1
解决办法
4745
查看次数

错误:“无法识别的参数:shell” - 适用于 Python 的 OAuth 2.0 Google API 客户端

我正在尝试进行纯粹的服务器端身份验证。我已遵循谷歌开发人员提供的代码示例中提到的所有过程。问题是execfile()在正常情况下工作正常python shell,但在python interactive shell.

以下是语句的日志。文件中还需要定义什么才能在Python Interactive Shellplaylistitems.py中执行。

代码playlistitems.py示例代码

Kshitij:trailers_backend Kshitij$ python manage.py shell
Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> execfile("playlistitems.py")
usage: manage.py [--auth_host_name AUTH_HOST_NAME] [--noauth_local_webserver]
                 [--auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]]
                 [--logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
manage.py: error: unrecognized arguments: shell
Kshitij:trailers_backend Kshitij$ 
Run Code Online (Sandbox Code Playgroud)

我通过更改本身的值来传递参数tools.py。以下是我收到的错误。我该如何解决?这个案例的端到端示例?

Traceback (most recent call …
Run Code Online (Sandbox Code Playgroud)

python shell oauth-2.0 google-oauth google-api-python-client

2
推荐指数
1
解决办法
3105
查看次数