tca*_*der 0 python django uwsgi
我试图在NGINX和uWSGI后面运行一个Django应用程序,但是datetime.today()从今天启动uWSGI服务器时返回日期时间时出现问题.该应用程序的配置如下:
<uwsgi>
<plugin>python</plugin>
<socket>127.0.0.1:3030</socket>
<chdir>/opt/ETS/bin</chdir>
<pythonpath>..</pythonpath>
<module>instance</module>
</uwsgi>
uWSGI的设置是默认设置,没有任何更改.
我怎样才能让日期时间重新开始?
澄清:在访问URL时,在此功能中进行调用
def create_file_header(name, ext):
return {'Content-Disposition': 'attachment; filename=%s-%s.%s' % (name, datetime.date.today(), ext) }
Run Code Online (Sandbox Code Playgroud)
来自urlpatten的电话:
(r'^loading_details/basic2/$', ExpandedResource(ReadLoadingDetailHandler, authentication=authentication,
headers=create_file_header('loading-details', 'csv')),
FORMAT_CSV, "api_loading_details_basic_auth"),
它在使用Apache WSGI托管在同一服务器上时起作用
如果存储datetime.date.today()在全局模块中,则只会在服务器启动时执行一次.这不是服务器问题,而是代码问题.
如果您需要显示今天日期的结果,则需要datetime.date.today()在需要今天的日期时调用callable,而不是在启动时.
即使您要调用today()函数,如果该函数本身仅在模块加载时调用,它仍然只执行一次.
URL模式仅生成一次.的headers关键字参数被每个URL被访问时不执行,而只在模块加载时.您需要将创建标题移动到视图本身.
| 归档时间: |
|
| 查看次数: |
908 次 |
| 最近记录: |