小编pat*_*eet的帖子

Django runserver in command with custom settings

我尝试使用自定义设置在命令中执行runserver.但是没有加载设置:

from django.core.management.base import BaseCommand
from django.core.management import call_command
from django.core.management import setup_environ, ManagementUtility

import settings_api

setup_environ(settings_api)

class Command(BaseCommand):
    help = "Local API to retrieve realtime quotes"

    def handle(self, *args, **options):
        if not settings_api.DEBUG:
            call_command('runserver',  '127.0.0.1:8002')
        else:
            call_command('runserver',  '0.0.0.0:8002')
Run Code Online (Sandbox Code Playgroud)

输出是:

Used API settings
Used API settings
Validating models...

0 errors found
Django version 1.4b1, using settings 'site.settings'
Development server is running at http://0.0.0.0:8002/
Quit the server with CONTROL-C.
Run Code Online (Sandbox Code Playgroud)

python django

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

Django鼻子只运行项目测试

我说nose,django-nose,nose-exclude,coverage我buildout.cfg就跑扩建.此外,我添加了TEST_RUNNERNOSE_ARGS我的settings.py.在最后一步中,我创建了一个exclude_dirs.txt并将其包含在NOSE_ARGS.这到目前为止工作.

最后,我跑去bin/django test运行我项目的测试.我发现内部的每个应用程序INSTALLED_APP都运行,甚至部分django核心模型都运行.如果没有exernal包,我怎么能将这个限制在我的项目中?

django code-coverage nose buildout

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

Python列表过滤器性能

我正在努力做到

In [21]: l1 = range(1,1000000)

In [22]: l2 = range(100,90000)

In [23]: l1.append(101)

In [24]: print(set([x for x in l1 if l1.count(x) - l2.count(x) == 1]))
Run Code Online (Sandbox Code Playgroud)

在我的python shell中,这需要很长时间.一般来说,我的目标是在处理重复项时从第二个列表中减去列表.

例如

[1,2,2,3] - [2,3] = [1,2]
Run Code Online (Sandbox Code Playgroud)

我很高兴有任何提示如何在普通的单核机器上完成最多500毫秒的工作.

python performance

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

标签 统计

django ×2

python ×2

buildout ×1

code-coverage ×1

nose ×1

performance ×1