小编And*_*unt的帖子

Postgres 函数 upper 不适用于西里尔文(版本 9.4)

这个问题类似于Postgres 不搜索不区分大小写的 unicode regex

但似乎该upper功能也不起作用?此外,似乎在服务器 utf8 上编码

我在 CentOS 6 上使用 webfaction 私有 postgres 实例,但不知道如何在创建集群时设置语言环境。

请帮忙,如何解决它。

sql postgresql unicode webfaction

4
推荐指数
1
解决办法
1848
查看次数

users_user_permissions 和 auth_permission 和 auth_group_permissions 有什么区别?

Django 使用syncdb 自动生成了上面的表,但我不明白这些表的用途。很抱歉问了愚蠢的问题,但我刚刚开始了解组和权限。

django django-models django-admin

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

如何在Python中对对象进行排序

假设我有lst一些对象的列表.

sorted(lst)如果未提供键功能,则使用什么值的对象?是散列还是一些id?

python sorting

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

字典值的惰性评估?

假设我有以下 dict d={'a': heavy_expression1, 'b': heavy_expression2}

如何包装表达式,以便在访问它们后对其进行求值,并且在此之后不执行求值?

d['a'] # only here heavy_expression1 is executed
d['a'] # no execution here, already calculated
Run Code Online (Sandbox Code Playgroud)

我需要使用lambda发电机吗?

python lazy-evaluation python-3.x

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

在谷歌地图中拖动带圆圈的标记,反之亦然

是否可以将标记"粘贴"到圆心?所以当我拖动标记圈时也会移动,反之亦然.

options = {
                    strokeColor: "#0000FF",
                    strokeOpacity: 0.35,
                    strokeWeight: 2,
                    fillColor: "#0000FF",
                    fillOpacity: 0.20
                };
                options.map = context.map;
                options.radius = radius;
                options.center = center;
                context.circle = new google.maps.Circle(options);
    var marker = new google.maps.Marker({
        position: new google.maps.LatLng(54.19335, -3.92695),
        map: _map,
        title: "",
        draggable: True
    });
Run Code Online (Sandbox Code Playgroud)

google-maps google-maps-markers

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

使用XMLHttpRequest时Django request.is_ajax返回False

我送跨域Ajax请求并在另一端request.is_ajax()False

var text = getSelectedText();
  text = 'text';
  if (text){
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            console.log(this.responseText)
        }
    };

    xhttp.open("GET", "http://example.com/text=" + encodeURIComponent(text), true);
    xhttp.send();}
Run Code Online (Sandbox Code Playgroud)

javascript django

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

AdBlock 阻止 MathJax 和 AddThis

启用 AdBlock 后,出现以下错误:

  1. 添加这个: Uncaught Error: Must pass a string which will eval to a globally accessible object where callbacks will be stored

  2. MathJax: Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' * 'unsafe-inline'".

当 AdBlock 被禁用时,一切正常。

问题出现在几周前。

即使启用了 AdBlock,在使用 MathJax 的网站上一切正常:https ://www.mathjax.org和https://math.stackexchange.com/

可能有些事情发生了变化,我需要正确更改代码。如何?

提前致谢。

javascript adblock addthis mathjax

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

Django render_to_string 行为

我有以下 HTML 文件 template.html:

{% load i18n %}
<p>{% blocktrans %}You have following email: {{ request.user.email }}.{% endblocktrans %}</p>
Run Code Online (Sandbox Code Playgroud)

现在在Python中:

if request.user is not None and request.user.is_authenticated():
   text = render_to_string('template.html', context_instance=RequestContext(request)))
Run Code Online (Sandbox Code Playgroud)

但 request.user.email 在模板中为空。即使我写了{{ user.email }},它仍然是空的。如何正确呈现用户并调用其方法?例如,{{ request.user.get_short_name }}也不起作用。

更新:问题在于{% blocktrans %}

<p>You have following email: {{ request.user.email }}.</p>
Run Code Online (Sandbox Code Playgroud)

有人能告诉为什么吗?我还没有翻译消息,但我认为它会按原样呈现。

python django django-templates

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

如果路径包含主目录tilde~,则不会执行Python子进程

我正在尝试检测错误并从django应用程序重新启动服务器.我正在使用以下代码:

try:
 # do something
except:
 print('here')
 subprocess.call(['/home/my_username/restart.sh'])
Run Code Online (Sandbox Code Playgroud)

restart.sh如下

#!/bin/sh
/home/my_username/webapps/app/apache2/bin/restart
/home/my_username/webapps/my_db/bin/cron
Run Code Online (Sandbox Code Playgroud)

我正在使用webfaction作为托管服务提供商.上面的代码打印语句,但不重启服务器,也不启动my_db下的mysql数据库.

也许我需要提供用户名/通行证?怎么做?

django python-2.7

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

在django / python中获取时区偏移

如何获取冬/夏令时的时区偏移量?

例如,如果时区是America / Monterrey,则我想分别获得冬季/夏季的数字-6和-5。

谢谢。

python django

0
推荐指数
1
解决办法
1375
查看次数