我尝试使用自定义设置在命令中执行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) 我说nose
,django-nose
,nose-exclude
,coverage
我buildout.cfg就跑扩建.此外,我添加了TEST_RUNNER
和NOSE_ARGS
我的settings.py.在最后一步中,我创建了一个exclude_dirs.txt
并将其包含在NOSE_ARGS
.这到目前为止工作.
最后,我跑去bin/django test
运行我项目的测试.我发现内部的每个应用程序INSTALLED_APP
都运行,甚至部分django核心模型都运行.如果没有exernal包,我怎么能将这个限制在我的项目中?
我正在努力做到
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毫秒的工作.