我在CentOS 6.7上使用Django 1.8和Apache Server版本:Apache/2.2.15(Unix).
我已经按照如何在CentOS 7上使用Apache和mod_wsgi服务Django应用程序中的步骤进行操作.
但是在最后一步,当我使用命令启动Apache服务器时:service httpd start而不是systemctl start httpd因为根据教程我没有Centos 6.7而不是CentOS 7.
它给出以下错误:
Starting httpd: Syntax error on line 10 of /etc/httpd/conf.d/django.conf:
Invalid command 'WSGIDaemonProcess', perhaps misspelled or defined by a module ot included in the server configuration
Run Code Online (Sandbox Code Playgroud)
你可以在这里查看django.conf:
Alias /static /home/ftpispy/ispy/static
<Directory /home/ftpispy/ispy/static>
Require all granted
</Directory>
<Directory /home/ftpispy/ispy/ispy>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess ispy python-path=/home/ftpispy/ispy:/home/ftpispy/ispy/venv/lib/python2.7/site-packages
WSGIProcessGroup ispy
WSGIScriptAlias / /home/ftpispy/ispy/ispy/wsgi.py …Run Code Online (Sandbox Code Playgroud) 我想迭代一个表的所有对象(Post)我在下面的代码中使用:
posts = Post.objects.all()
for post in posts:
process_post(post)
Run Code Online (Sandbox Code Playgroud)
process_post 是一个芹菜任务,将在后台运行,而不是更新post.But我遇到的问题是Post表有100万条记录.这不是一次性的工作.我每天都在运行它.
for post in posts
Run Code Online (Sandbox Code Playgroud)
在上面的行中,调用Query,它一次性从DB中获取所有数据.
如何改善其性能?有没有什么方法可以批量获取数据?