我希望我的 api 返回按模型中的字段Account分组的对象。account_type我想这样做,以便在我的 JS 代码中更容易访问分组帐户。这是现在返回的内容:
[{
"id": 6,
"owner": 1,
"account_name": "Credit Card 1",
"account_type": "credit card",
"created_time": "2019-07-18T02:57:44.288654Z",
"modified_time": "2019-07-18T02:57:44.288842Z"
}, {
"id": 11,
"owner": 1,
"account_name": "Savings 1",
"account_type": "savings",
"created_time": "2019-07-18T03:00:22.122226Z",
"modified_time": "2019-07-18T03:00:22.122283Z"
}, {
"id": 5,
"owner": 1,
"account_name": "Checking 1",
"account_type": "checking",
"created_time": "2019-07-18T02:57:28.580268Z",
"modified_time": "2019-07-18T02:57:28.580305Z"
}, {
"id": 9,
"owner": 1,
"account_name": "Savings 2",
"account_type": "savings",
"created_time": "2019-07-18T02:59:57.156837Z",
"modified_time": "2019-07-18T02:59:57.156875Z"
}, {
"id": 10,
"owner": 1,
"account_name": "Savings 3",
"account_type": …Run Code Online (Sandbox Code Playgroud) macOS Catalina
我有一个应该将文件写入外部驱动器的 python 脚本。如果我手动运行脚本,这会起作用。但是,如果该脚本是从 LaunchAgent bash 脚本启动的,则它无权这样做。
例如,简化的 python 脚本:
with open('/Volumes/nas_1/test/somefile.txt', 'a') as the_file:
the_file.write('Hello\n')
Run Code Online (Sandbox Code Playgroud)
LaunchAgent 启动的 Bash 脚本位于/Applications:
#!/bin/bash
#Start test script only if it is not running
if [ "$(ps -ef | grep -v grep | grep python_test.py | wc -l)" -le 0 ]
then
echo "Python Test Starting"
/Users/admin-user/.venvs/test/bin/python /Users/admin-user/projects/test/scripts/python_test.py
else
echo "Python Test Already Running"
fi
Run Code Online (Sandbox Code Playgroud)
plist 位于~/Library/LaunchAgents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> …Run Code Online (Sandbox Code Playgroud) 我正在尝试重组我的项目,以符合最新的《Two Scoops of Django》一书(针对 Django 1.11)中的建议。
\n\n完成重组后,我的应用程序无法导入。
\n\nsecureDash_project\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 README.rst\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 config\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __init__.py\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __pycache__\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 db.sqlite3\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 settings\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __init__.py\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __pycache__\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 settings.py\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 urls.py\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 wsgi.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 db.sqlite3\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 manage.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 requirements.txt\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 secureDash\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __init__.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __pycache__\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 dash\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __init__.py\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __pycache__\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 admin.py\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 apps.py\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 forms.py\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 migrations\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 __init__.py\n …Run Code Online (Sandbox Code Playgroud)