我是gunicorn 的新手,正在尝试在ubuntu 上部署django 网站。我用过了:
pip3 install gunicorn
sudo apt-get install gunicorn
Run Code Online (Sandbox Code Playgroud)
但是当我想填充这个文件时:
sudo nano /etc/systemd/system/gunicorn.service
Run Code Online (Sandbox Code Playgroud)
我用以下内容填充:
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/myprojectdir
ExecStart=/home/sammy/myprojectdir/myprojectenv/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
myproject.wsgi:application
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
但是没有gunicorn文件,/bin
缺少的部分是什么?
通过使用这个命令:
sudo journalctl -u gunicorn.socket
sudo systemctl status gunicorn
Run Code Online (Sandbox Code Playgroud)
Gunicorn.service:在步骤 EXEC 生成 /home/tw/tw_git2/tw_git2/ninipayenv/bin/gunicorn 时失败:没有这样的文件或目录
我正在使用 ubuntu 18.0.4 并且我有一个 postgresql 数据库。显然我已经安装了postgresql。我也已经安装了postgis:
sudo apt install postgis postgresql-11-postgis-2.5
Run Code Online (Sandbox Code Playgroud)
通过使用这个命令:
dpkg -l | grep postgresq
Run Code Online (Sandbox Code Playgroud)
它返回:
ii pgdg-keyring 2018.2
all keyring for apt.postgresql.org
ii postgresql 12+210.pgdg18.04+1
all object-relational SQL database (supported version)
ii postgresql-11 11.6-1.pgdg18.04+1
amd64 object-relational SQL database, version 11 server
ii postgresql-11-postgis-2.5 2.5.3+dfsg-2.pgdg18.04+1
amd64 Geographic objects support for PostgreSQL 11
ii postgresql-11-postgis-2.5-scripts 2.5.3+dfsg-2.pgdg18.04+1
all Geographic objects support for PostgreSQL 11 -- SQL scripts
ii postgresql-12 12.1-1.pgdg18.04+1
amd64 object-relational SQL database, version 12 server
ii postgresql-client-11 11.6-1.pgdg18.04+1 …Run Code Online (Sandbox Code Playgroud) 我需要在每个循环中生成唯一的 id,而不是````城市选择```
{% for form in formset.forms %}
<tr>
{% for field in form %}
<td class="input_td{% if field.errors %} error_td{% endif %}">
<select name="city-select" id="city-select"></select>
</td>
{% endfor %}
<td class="delete_formset_td"></td>
</tr>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
我怎样才能在这里生成它?
我需要这样的 ids :
输出:
city-1
city-2
city-3
...
Run Code Online (Sandbox Code Playgroud) 我想对查询集中的所有对象应用一种方法,然后对它们进行排序。
products = Product.objects.all()
for product in products:
product.update_exist_flag()
products = products.order_by('-exist_flag')
Run Code Online (Sandbox Code Playgroud)
它会引发此错误:
AssertionError:获取切片后无法重新排序查询。
我该如何修复它?