我正在使用本指南: http: //www.jeffknupp.com/blog/2012/02/09/starting-a-django-project-the-right-way/
设置我的 django 项目。但我被困在部署部分。我在我的 virtualenv 中使用 pip 安装了结构。我在 myproject 目录中创建了这个文件:
from fabric.api import local
def prepare_deployment(branch_name):
local('python manage.py test finance')
local('git add -p && git commit')
local('git checkout master && git merge ' + branchname)
from fabric.api import lcd
def deploy():
with lcd('home/andrius/djcode/myproject/'):
local('git pull /home/andrius/djcode/dev/')
local('python manage.py migrate finance')
local('python manage.py test finance')
local('/my/command/to/restart/webserver')
但是当我输入这个命令时(如指南所示):
晶圆厂prepare_deployment
我收到此错误:
Traceback (most recent call last):
File "/home/andrius/env/local/lib/python2.7/site-packages/fabric/main.py", line 732, in main
*args, **kwargs
File "/home/andrius/env/local/lib/python2.7/site-packages/fabric/tasks.py", line 345, in execute
results['<local-only>'] = task.run(*args, **new_kwargs)
File "/home/andrius/env/local/lib/python2.7/site-packages/fabric/tasks.py", line 121, in run
return self.wrapped(*args, **kwargs)
TypeError: prepare_deployment() takes exactly 1 argument (0 given)
因此,即使它没有在指南中指定输入参数,我想它也需要我的分支名称。所以输入了这个:
晶圆厂prepare_deployment v0.1
(v0.1 是我的分支名称)所以现在我收到了这个错误:
Warning: Command(s) not found:
v0.1
Available commands:
deploy
prepare_deployment
我还注意到在函数 prepare_deployment 中的文件 fabfile.py 的指南中,输入写为“branch_name”,并且在函数内部有参数“branchname”。所以我认为它应该是相同的并将'branchname'重命名为'branch_name',但仍然得到相同的错误。
所以我认为我在这里做错了什么。可能是什么问题呢?
更新:我试图在 fabfile.py 中调用函数:
准备部署(“v0.1”)
输出是这样的:
[localhost] local: python manage.py test finance
Creating test database for alias 'default'...
Got an error creating the test database: permission denied to create database
Type 'yes' if you would like to try deleting the test database 'test_finance', or 'no' to cancel: yes
Destroying old test database 'default'...
Got an error recreating the test database: database "test_finance" does not exist
Fatal error: local() encountered an error (return code 2) while executing 'python manage.py test finance'
Aborting.
我想我还应该提到我的应用程序名称是“金融”作为数据库名称“金融”。也许这些是矛盾的?