社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

Vikas Gautam

Vikas Gautam 最近回复了
6 年前
回复了 Vikas Gautam 创建的主题 » 使用django get_queryset()返回字典列表

因为我怀疑错误来自数据库。 我改了这个

    {
"result" : [ 
        {
            "savings" : 43.0548666420733,
            "count" : 18
        }, 
        {
            "savings" : 387.651510654053,
            "count" : 161
        }],
    }

为了这个

    {
"result" : {"data":[ 
        {
            "savings" : 43.0548666420733,
            "count" : 18
        }, 
        {
            "savings" : 387.651510654053,
            "count" : 161
        }]}
    }

现在一切都很好。 基本上, result 属于 array 我把它改成了 object

5 年前
回复了 Vikas Gautam 创建的主题 » 如何在Pythonanywhere中安装django wkhtmltopf。?

我不确定pythonanywhere,但在windows中,我下载了wkhtmltox.zip,在其中,我发现 wkhtmltox.exe . 您还需要安装 wkhtmltox .

import imgkit
config_img = imgkit.config(wkhtmltoimage='../path_of_wkhtmltopdf/wkhtmltox.exe')  #in windows
config_img = imgkit.config(wkhtmltoimage='../path_of_wkhtmltopdf/wkhtmltox')   #in linux
imgkit.from_string(html, file_path + '.jpg', config=config_img) 

对于蟒蛇

上传 wkhtmltox公司 文件从上载选项存在于 file 剖面图 pythonanywhere .

检查当前目录并列出该目录中的文件,然后找到您的文件。

import os
print(os.getcwd())                   # current directory path

print(os.listdir(os.getcwd())        # list files present in current directory
6 年前
回复了 Vikas Gautam 创建的主题 » 连接MongoDB和Django

首先感谢你在这个问题上的回答和支持。

我同意 旧业 什莱什卡蒂 答案,我们可以使用mongoclient和mongoengine来连接mongodb,两者都很好。

我找到了另一种方法,有一个开源项目 djongo 我在用 琼戈 连接 MongoDB 数据库。主要好处 琼戈 它能让你使用一切 django 提供(例如models.model)。

以下是 琼戈 Github页面 https://github.com/nesdis/djongo

这是我们需要使用djongo的设置 设置.py

DATABASES = {
'default': {
    'ENGINE': 'djongo',
    'NAME': 'MyDB',
}

}