小编RuS*_*uSs的帖子

django:TypeError:'tuple'对象不可调用

获取类型错误,'tuple'对象不可调用.知道它可能是什么?(不要担心缩进.它复制很奇怪.)我正在尝试根据商店的PackSize创建选择.

Views.py:

def storeliquor(request, store_id, liquor_id):        
a = StoreLiquor.objects.get(StoreLiquorID=liquor_id)
s = Store.objects.get(StoreID=store_id)
x = Order.objects.get(storeID=s, Active=True)
y = a.OffPremisePrice
c = a.BottleSize

g = request.POST.get('OrderAmount', '')
b = a.PackSize
h = b*2
d = b*3
e = b*4
r = b*5
if c == "1750 ML":
    pack_size = (
        ('1', '1')
        ('3', '3')
        (b, b)
        (h, h)
        (d, d)
        (e, e)
        (r, r)
    )
elif c == "1000 ML":
    pack_size = (
        ('1', '1')
        ('3', '3')
        ('6', '6')
        (b, b) …
Run Code Online (Sandbox Code Playgroud)

python django tuples typeerror

24
推荐指数
1
解决办法
13万
查看次数

django SyntaxError:关键字不能是表达式

在以下代码行中出现语法错误。我已经导入了数学,但是我的更新功能仍然无法正常工作。告诉我关键字不能是表达式,并且引用了最后3行。知道我在做什么错吗?

StoreLiquor.objects.filter(storeID=ID_Store, liquorID.BottleSize='750 ML', custom=False).update(StorePrice = liquorID.ShelfPrice)

StoreLiquor.objects.filter(storeID=ID_Store, liquorID.BottleSize='750 ML', custom=False).update(StorePrice = (float(liquorID.OffPremisePrice)) + (float(S750Increase)))

StoreLiquor.objects.filter(storeID=ID_Store, liquorID.BottleSize='750 ML', custom=False).update(StorePrice = (float(liquorID.OffPremisePrice) * (float(S750Increase)/100)) + float(liquorID.OffPremisePrice))
Run Code Online (Sandbox Code Playgroud)

python django

5
推荐指数
1
解决办法
5521
查看次数

django reportlab 将pdf附加到电子邮件,将pdf保存到服务器,在浏览器中显示pdf

我有 3 个关于使用 django 中的报告实验室生成的 pdf 的问题,我似乎找不到一个好的答案。django 站点上的文档仅介绍如何生成 pdf 供下载。但是如何将生成的 pdf 附加到电子邮件中并发送而不是下载呢?如何将 pdf 保存到服务器上的目录而不是下载?如何在浏览器窗口中显示 pdf 文件而不是下载它?只需使用 django 文档示例:

from reportlab.pdfgen import canvas
from django.http import HttpResponse

def some_view(request):
    # Create the HttpResponse object with the appropriate PDF headers.
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'attachment; filename="somefilename.pdf"'

    # Create the PDF object, using the response object as its "file."
    p = canvas.Canvas(response)

    # Draw things on the PDF. Here's where the PDF generation happens.
    # See the ReportLab documentation for the full …
Run Code Online (Sandbox Code Playgroud)

django pdf-generation reportlab

2
推荐指数
1
解决办法
3476
查看次数

mysql存储过程错误(1172,'结果由多行组成')

当试图从django运行以下存储过程时,我得到一个OperationError(1172,'结果由多行组成')任何想法我可能做错了什么?

-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `UpdatePrices`(IN storeId int, IN bottleSize VARCHAR(50))
BEGIN
    DECLARE amount DECIMAL(10,2); DECLARE isCustom INT DEFAULT 0;
    DECLARE changeType VARCHAR(50) DEFAULT 'State'; DECLARE updateType INT DEFAULT 0;

        IF bottleSize = '1000 Ml' THEN
            SELECT S1000IncreaseChoices INTO changeType FROM store_store WHERE StoreID = storeId;

            IF changeType = 'State' THEN
                SELECT updateType = 0;
            END …
Run Code Online (Sandbox Code Playgroud)

mysql django stored-procedures

2
推荐指数
1
解决办法
2万
查看次数