django - 使用特殊字符在 Heroku(通过 powershell)中设置环境变量

标签 django powershell heroku environment-variables

Django 1.8、Heroku、Powershell。

我正在尝试为 Heroku 中的 django key 设置环境变量:

(venv) PS WORKFOLDER> heroku config:set SECRET_KEY=eoik6-&dnr9elgmrt7-%3hu_&37$3hg!9c6x!^khjr3!z*z&b4

我收到此错误消息(3 次 - 因为字符串中有 3 个&符号):
At line:1 char:77
+ heroku config:set SECRET_KEY=eoik6-&dnr9elgmrt7-%3hu_&37$3hg!9c6x!^khjr3!z*z&b4
+                                                                             ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double
quotation marks ("&") to pass it as part of a string.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : AmpersandNotAllowed

当我尝试建议的解决方案时(在 & 符号周围加上双引号):
(venv) PS WORKFOLDER> heroku config:set SECRET_KEY=eoik6-"&"dnr9elgmrt7-%3hu_"&"37$3hg!9c6x!^khjr3!z*z"&"b4

我收到此错误:
SECRET_KEY: eoik6-
'dnr9elgmrt7-%3hu_' is not recognized as an internal or external command, operable program or batch file.
'37$3hg!9c6x!^khjr3!z*z' is not recognized as an internal or external command, operable program or batch file.
'b4' is not recognized as an internal or external command, operable program or batch file.

我也尝试用斜杠转义,在整个字符串周围加上引号等。结果相同。那么如何设置我的环境变量呢?

最佳答案

我不熟悉 Heroku,但假设 heroku 是可执行的并且 config:set SECRET_KEY=eo... 是命令行参数,你可以试试这个:

& 'heroku' @('config:set', 'SECRET_KEY=eoik6-"&"dnr9elgmrt7-%3hu_"&"37$3hg!9c6x!^khjr3!z*z"&"b4')

关于django - 使用特殊字符在 Heroku(通过 powershell)中设置环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32130105/

相关文章:

java - 使用 SendGrid 在 Heroku 中发送邮件

python - Django SSL Redirect 片段修改,未按预期工作

python - 新建 Postgresql 数据库 : column "id" is of type integer but expression is of type uuid when creating super user

powershell - 受域保护的 pfx 需要什么密码?

powershell - 使用 cer/pem 进行身份验证的给定 curl 的 powershell 等效项是什么?

用于 IODocs 的 Heroku 上的 node.js 和 Redis

django - 删除在特定字段中具有重复值的 Django QuerySet 对象

Django通用关系字段报告未传递args时all()正在获得意外的关键字参数

powershell - 使用参数从powershell提示符运行powershell

ruby - 工头从手动路径开始