小编Raj*_*mon的帖子

如何解决聚合物项目中没有'Access-Control-Allow-Origin'?

现在我正在探索Polymer-project 1.0,任务是JSON重复获取和打印输出.

但无论我尝试下面的错误即将到来,即使我试过Github pages也在终端给我同样的错误响应

错误

XMLHttpRequest无法加载https://ajax.googleapis.com/ajax/services/search/news?v=1.0&rsz=8&pz=1&cf=all&ned=in&hl=en&topic=tc.请求的资源上不存在"Access-Control-Allow-Origin"标头.因此,不允许访问" http://rajasimon.github.io ".

没有进入主题和设计材料设计...我想要的功能将首先工作.所以我在下面写了代码......

的index.html

<iron-ajax
  auto
  url="https://ajax.googleapis.com/ajax/services/search/news?v=1.0&rsz=8&pz=1&cf=all&ned=in&hl=en&topic=tc"
  handle-as="json"
  last-response="{{ajaxResponse}}"></iron-ajax>

  <template is="dom-repeat" items="{{ajaxResponse.responseData.results}}">
        <paper-material elevation="1" class="paper-font-body2">
              <h1>{{item.title}}</h1>
              <iron-image src="[[item.image.url]]" style="width:800px; height:450px; background-color: lightgray;" sizing="cover"  preload fade></iron-image>
              <p>{{item.content}}</p>
        </paper-material>
  </template>
Run Code Online (Sandbox Code Playgroud)

启用

为了调试我安装了谷歌Chrome应用程序命名Allow-Control-Allow-Origin: *然后上面的代码开始工作...

在此输入图像描述

即使我尝试使用铁-ajax演示也会给出相同的结果.这里发生了什么事.我是宇宙中接收此错误的人吗?

ajax polymer polymer-1.0

14
推荐指数
1
解决办法
7729
查看次数

TypeError:在include()的情况下,view必须是可调用的或list/tuple

我是django和python的新手.在url映射到视图期间,我遇到以下错误:TypeError:在include()的情况下,view必须是可调用的或list/tuple.

网址.py代码: -

from django.conf.urls import url
from django.contrib import admin


urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^posts/$', "posts.views.post_home"), #posts is module and post_home 
]                                              # is a function in view. 
Run Code Online (Sandbox Code Playgroud)

views.py代码: -

from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
#function based views

def post_home(request):
    response = "<h1>Success</h1>"
    return HttpResponse(response)
Run Code Online (Sandbox Code Playgroud)

追溯

在此输入图像描述

django python-2.7 python-3.x

11
推荐指数
1
解决办法
3万
查看次数

ARM64 分支超出范围

编译到设备(Iphone 5s)时,我收到以下编译错误:

最后部分布局:

    __TEXT/__text addr=0x1000044B4, size=0x0AC5D808, fileOffset=0x000044B4, type=1

...


ld: b(l) ARM64 branch out of range (180743200 max is +/-128MB): from __ZN10ClassNameEv (0x100004560) to __Unwind_Resume@0x00000000 (0x10AC6351C) 
in '__ZN10ClassNameC2Ev' from  /Users/Name/Desktop/Projectpath/Debug-iphoneos/Project.build/Objects-normal/arm64/ClassName.o for  architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

"Valid Architectures""armv7 armv7s arm64"

"Build Active Architecture Only"NO

问题:你知道我能做些什么吗?

xcode ios arm64

5
推荐指数
0
解决办法
2547
查看次数

Heroku'DATABASES'没有定义

我正在尝试使用django应用程序在Heroku上工作.

我一直收到这个错误:

Running `./manage.py migrate` attached to terminal... up, run.5743
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/__init__.py", line 345, in execute
    settings.INSTALLED_APPS
  File "/app/.heroku/python/lib/python3.4/site-packages/django/conf/__init__.py", line 46, in __getattr__
    self._setup(name)
  File "/app/.heroku/python/lib/python3.4/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/app/.heroku/python/lib/python3.4/site-packages/django/conf/__init__.py", line 94, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/app/.heroku/python/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen …
Run Code Online (Sandbox Code Playgroud)

python django heroku

3
推荐指数
1
解决办法
2005
查看次数

从 VSCODE 运行 Django 项目

有没有办法从 VSCODE 编辑器运行 Django 项目?

目前我使用 Windows CMD 来运行我的项目。每次当我在 VSCODE 上点击“运行”按钮时,它都不会运行该项目。

在 pyCharm 上,我们可以将“runserver”添加到其脚本参数配置中。VSCode 上有类似的东西吗?

更新

我在 VSCODE 终端上得到这个:

Type 'manage.py help <subcommand>' for help on a specific subcommand.

Available subcommands:

[auth]
    changepassword
    createsuperuser

[contenttypes]
    remove_stale_contenttypes

[django]
    check
    compilemessages
    createcachetable
    dbshell
    diffsettings
    dumpdata
    flush
    inspectdb
    loaddata
    makemessages
    makemigrations
    migrate
    sendtestemail
    shell
    showmigrations
    sqlflush
    sqlmigrate
    sqlsequencereset
    squashmigrations
    startapp
    startproject
    test
    testserver

[sessions]
    clearsessions

[staticfiles]
    collectstatic
    findstatic
    runserver

[Done] exited with code=0 in 9.449 seconds
Run Code Online (Sandbox Code Playgroud)

django visual-studio-code

3
推荐指数
1
解决办法
9166
查看次数

如何在Django模板中获取日期格式

我是django的新手。在我的模板中,我需要当前日期作为日期格式,而以下代码返回字符串:

<p>{% now "Y-m-d" as date %}</p>
Run Code Online (Sandbox Code Playgroud)

我想以2018-12-17格式的日期作为日期而不是字符串。反正有这样做吗?

恶作剧

django date

3
推荐指数
1
解决办法
4182
查看次数

paramiko通过sftp上传文件夹

在我的工作代码中,我有这个

import paramiko
parent=os.path.split(dir_local)[1]
for walker in os.walk(parent):
    try:
        self.sftp.mkdir(os.path.join(dir_remote,walker))
    except:
        pass
for file in walker[2]:
    sftp.put(os.path.join(walker[0],file),os.path.join(dir_remote,walker[0],file))
Run Code Online (Sandbox Code Playgroud)

现在显示的错误是

Trying ssh-agent key 5e08bb83615bcc303ca84abe561ef0a6 ... success
Caught exception: <type 'exceptions.IOError'>: [Errno 2] Directory does not exist.
Run Code Online (Sandbox Code Playgroud)

打印walker显示该文件夹中的所有文件,但我不知道为什么该文件夹不会复制到sftp服务器

python ssh sftp paramiko

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

ImportError:使用chatterbot时没有名为db的模块

我正在尝试建立一个聊天机器人.所以我安装了chatterbot包.python代码如下:

from chatterbot import TalkWithCleverbot
talk = TalkWithCleverbot()
talk.begin()
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:

 Traceback (most recent call last):
 File "C:\Users\JERIN\Desktop\bottobot.py", line 2, in <module>
   talk = TalkWithCleverbot()
 File "C:\Python27\lib\site-packages\chatterbot\__init__.py", line 157, in     __init__
 super(TalkWithCleverbot, self).__init__()
 File "C:\Python27\lib\site-packages\chatterbot\__init__.py", line 4, in  __init__
 from jsondb.db import Database
 ImportError: No module named db
Run Code Online (Sandbox Code Playgroud)

我尝试安装jsondb和db软件包,但没有好处.请帮我

python python-2.7 chatterbot

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

django 在某处引发异常

SOCIAL_AUTH_PIPELINE = (
    'social.pipeline.social_auth.associate_by_email',
)
Run Code Online (Sandbox Code Playgroud)

通过使用上面的代码settings.py我可以避免...

(1062, "Duplicate entry 'example@example.com' for key 'email'")错误信息。

但我在网上搜索,发现这个方便的代码可以放入exception所需的 html 页面中:

[代码1]: #backends.py

class MySocialAuthExceptionMiddleware(SocialAuthExceptionMiddleware):
    def process_exception(self, request, exception):
        msg = None
        if #no duplicate email:
            return HttpResponse("# catched exception")
        else:
            # processing msg here
            return render_to_response(# html, {msg}, context)
Run Code Online (Sandbox Code Playgroud)

# 设置.py

MIDDLEWARE_CLASSES = (
    'frontend.backends.MySocialAuthExceptionMiddleware'
)
Run Code Online (Sandbox Code Playgroud)

我的问题是solved基于上面的代码。但之前我使用以下代码使用了另一种功能,它与上述概念完全不同。

[代码2]:

def function(request):
    #actual code here
    return HttpResponse('msg here')
Run Code Online (Sandbox Code Playgroud)

但是在运行上面的代码时,我收到了类似的错误消息,

tuple index out of range在这个MySocialAuthExceptionMiddleware..

实际上,对于上述代码来说,这不是正确的错误消息。该消息与“ [Code …

python django django-views python-social-auth

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