小编cli*_*ime的帖子

Django:NotperlyConfigured:SECRET_KEY设置不能为空

我正在尝试设置包含一些基本设置的多个设置文件(开发,生产,...).虽然不能成功.当我尝试运行时,./manage.py runserver我收到以下错误:

(cb)clime@den /srv/www/cb $ ./manage.py runserver
ImproperlyConfigured: The SECRET_KEY setting must not be empty.
Run Code Online (Sandbox Code Playgroud)

这是我的设置模块:

(cb)clime@den /srv/www/cb/cb/settings $ ll
total 24
-rw-rw-r--. 1 clime clime 8230 Oct  2 02:56 base.py
-rw-rw-r--. 1 clime clime  489 Oct  2 03:09 development.py
-rw-rw-r--. 1 clime clime   24 Oct  2 02:34 __init__.py
-rw-rw-r--. 1 clime clime  471 Oct  2 02:51 production.py
Run Code Online (Sandbox Code Playgroud)

基本设置(包含SECRET_KEY):

(cb)clime@den /srv/www/cb/cb/settings $ cat base.py:
# Django base settings for cb project.

import django.conf.global_settings as defaults

DEBUG = False …
Run Code Online (Sandbox Code Playgroud)

python django settings

81
推荐指数
10
解决办法
11万
查看次数

postgreSQL:如何复制一行

这是我的表web_book的方案:

     Column     |          Type          |                       Modifiers                       
----------------+------------------------+-------------------------------------------------------
 id             | integer                | not null default nextval('web_book_id_seq'::regclass)
 page_count     | integer                | not null
 year_published | integer                | not null
 file           | character varying(100) | not null
 image          | character varying(100) | not null
 display_on_hp  | boolean                | not null
 name           | character varying(128) | not null
 description    | text                   | not null
 name_cs        | character varying(128) | 
 name_en        | character varying(128) | 
 description_cs | text                   | 
 description_en | text                   |
Run Code Online (Sandbox Code Playgroud)

该表包含一行id=3 …

postgresql

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

uWSGI:--master with --emperor产生两个皇帝

我可以看到,如果我像这样启动uwsgi:

sudo /usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --uid www --gid www
Run Code Online (Sandbox Code Playgroud)

它创造了一个皇帝副本.但是如果我--master另外启动它(这里推荐),它会创建两个皇帝副本.是否有意义使用--master--emperor?我会说不,但如果我在没有该选项的情况下运行它,我会收到此警告:

*** WARNING: you are running uWSGI without its master process manager ***

uwsgi

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

在chrome的控制台中添加自定义功能

是否可以在google-chrome中使用自定义功能,这些功能将始终在控制台中可用(无论加载哪个页面)?例如,我想有一个名为echo的函数,它只是console.log的一个包装器.这只是节省了一些输入,但后来我可能想要创建一些有用的调试功能.

javascript console customization google-chrome

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

inno db隔离级别和锁定

我正在阅读一本关于innodb交易的手册,但仍然有很多不清楚的东西给我.例如,我不太了解以下行为:

-- client 1                             -- client 2
mysql> create table simple (col int) 
       engine=innodb; 

mysql> insert into simple values(1);
Query OK, 1 row affected (0.00 sec)

mysql> insert into simple values(2);
Query OK, 1 row affected (0.00 sec)

mysql> select @@tx_isolation;                                                              
+-----------------+                                                                         
| @@tx_isolation  |
+-----------------+
| REPEATABLE-READ |                                                                         
+-----------------+

mysql> begin;                                    
Query OK, 0 rows affected (0.01 sec)            
                                        mysql> begin;
                                        Query OK, 0 rows affected (0.00 sec)

mysql> update simple set col=10 where col=1;
Query OK, 1 row affected …
Run Code Online (Sandbox Code Playgroud)

mysql innodb transactions isolation-level database-locking

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

django形式:绑定表单的默认值

使用此表单:

class Form(forms.Form):
    name = forms.CharField(required=False, initial='Hello world')
Run Code Online (Sandbox Code Playgroud)

如果我在视图中执行以下操作:

form = Form(request.GET)
if form.is_valid():
    name = form.cleaned_data['name']
Run Code Online (Sandbox Code Playgroud)

然后,即使request.GET不包含name键,也会丢失name的初始值.有没有解决方法?我希望初始值可以将表单绑定为"默认值".

forms django

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

hg更新错误

尝试运行时出现以下错误hg update:

abort: Operation not permitted:
/var/www/simira/web/public/images/nominations/13/big/4f196667cf5a2.jpg
Run Code Online (Sandbox Code Playgroud)

这是一些信息:

$ cd /var/www/simira/web/public/images/nominations/13/big/
$ ll ./4f196667cf5a2.jpg 
-rw-rw-r-- 1 martin portadesign 15356 Feb  2 22:10 4f196667cf5a2.jpg
$ ll -d ./
drwxrwxr-x 2 martin portadesign 4096 Feb  2 22:10 ./
$ id
uid=5004(clime) gid=5007(portadesign) groups=5007(portadesign),10(wheel),48(apache)
Run Code Online (Sandbox Code Playgroud)

告诉我有什么问题,拜托...

mercurial

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

magnific popup中的select2:搜索输入无法聚焦

我使用select2 jquery插件和magnific弹出窗口.如果我在打开的弹出窗口中单击选择,则会显示包含某些结果的搜索框.问题是无法在搜索框中输入任何内容 - 光标就不会出现.这是jsfiddle,它演示了问题http://jsfiddle.net/clime/qweWa/15/.代码如下:

# html
<a href="#test-popup" class="open-popup-link">Show inline popup</a>

<div id="test-popup" class="white-popup mfp-hide">
    <select id="focus-blur-loop-select">
        <option>hello</option>
        <option>world</option>
    </select>
</div>

# js
$(function() {
  $('.open-popup-link').magnificPopup({
    type:'inline',
    midClick: true
  });

  $('#focus-blur-loop-select').select2({
      width: '200px'
  });
});

# css
.white-popup {
  position: relative;
  background: #FFF;
  padding: 20px;
  width: auto;
  max-width: 500px;
  margin: 20px auto;
}
Run Code Online (Sandbox Code Playgroud)

我已经完成了一些基础研究,并且我发现下面的两个回调被称为unfinetly.事件中似乎存在一些无限循环.

// select2.js:742
search.on("focus", function () { search.addClass("select2-focused"); });
search.on("blur", function () { search.removeClass("select2-focused");});
Run Code Online (Sandbox Code Playgroud)

jquery jquery-select2 magnific-popup

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

从两个不同的表中按列排序时,PostgreSQL查询的速度会变慢

以前,我使用了这个查询,速度很快:

cb=# explain analyze SELECT "web_route"."id", "web_crag"."id" FROM "web_route" 
INNER JOIN "web_crag" ON ( "web_route"."crag_id" = "web_crag"."id" )
WHERE "web_crag"."type" IN (1, 2) 
ORDER BY "web_crag"."name" ASC
LIMIT 20;
                                                                 QUERY PLAN                                                                  
---------------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=0.00..2.16 rows=20 width=18) (actual time=0.027..0.105 rows=20 loops=1)
   ->  Nested Loop  (cost=0.00..47088.94 rows=436055 width=18) (actual time=0.026..0.100 rows=20 loops=1)
         ->  Index Scan using web_crag_name on web_crag  (cost=0.00..503.16 rows=1776 width=14) (actual time=0.011..0.020 rows=14 loops=1)
               Filter: (type = ANY ('{1,2}'::integer[]))
         ->  Index Scan using web_route_crag_id on web_route  (cost=0.00..23.27 rows=296 width=8) (actual …
Run Code Online (Sandbox Code Playgroud)

sql postgresql optimization

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

vim wildmenu:使用与 &lt;down&gt; 不同的键进入子目录

这已经困扰我很长时间了。我喜欢使用wildmenu 在命令模式下浏览目录。问题是,为了进入子目录,我需要使用<down>总是遥不可及的密钥。我试图做一些映射来克服这个问题,但没有成功。例如:

cnoremap <C-j> <DOWN>
Run Code Online (Sandbox Code Playgroud)

但是,如果我<C-j>想在wildmenu 中进入子目录时按,则菜单会消失并^I出现在命令行的末尾。知道如何解决这个问题吗?

vim

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