Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 方法反向django误差_Python_Django_Reverse - Fatal编程技术网

Python 方法反向django误差

Python 方法反向django误差,python,django,reverse,Python,Django,Reverse,我正在使用反向调用一个方法,但我有一个我无法理解的问题论点。 我的错误: 找不到参数为“(35,)”且关键字参数为“{}”的“shopping.views.payment_confirmation”的反面 我的网址: url(r'^payment_confirmation/(?P<id>\d+\d{2\})/$', 'payment_confirmation', name='payment_confirmation'), 我的付款模式: class Payment(models.M

我正在使用反向调用一个方法,但我有一个我无法理解的问题论点。 我的错误: 找不到参数为“(35,)”且关键字参数为“{}”的“shopping.views.payment_confirmation”的反面

我的网址:

url(r'^payment_confirmation/(?P<id>\d+\d{2\})/$', 'payment_confirmation', name='payment_confirmation'),
我的付款模式:

class Payment(models.Model):
    ...
    ...
    def submit(self, redirect_url):
        '''
            Sends self as a Payment through PagSeguro API.
            Payment instance MUST BE SAVED before calling this method.
        '''

        if not self.id:
            #Temporary to identify which problem caused the crash.
            raise ValidationError

        #creating a reference if its None
        if self.reference is None:
            self.reference = configs.PAGSEGURO_REFERENCE_PREFIX + str(self.id)

        document = Document()
        document.appendChild(self.to_element(document, redirect_url))

        response = document2dict(api.submit_payment(document))

        try:
            self.code = response['checkout']['code']
            self.answered_on = datetime.datetime.now()
            self.save()
        except:
            error_str = ""
            if type(response["errors"]["error"]) != list:
                response["errors"]["error"] = [response["errors"]["error"]]
            for error in response["errors"]["error"]:
                error_payment = ErrorPayment()
                error_payment.code = int(error['code'])
                error_payment.payment = self
                error_payment.save()
                error_str += "[%s: %s]" % (error_payment.code,
                                           error_payment.get_code_display())
            raise Exception(error_str)
错误出现在这里payment.submit(settings.SITE\u URL+reverse(“shopping.views.payment\u confirmation”,args=[payment.id])) I',使用此api此行:reverse(“shopping.views.payment\u confirmation”,args=[payment.id])告诉Django在购物应用程序的views.py文件中找到一个与payment\u confirmation方法匹配的url,该方法将接受支付id参数

在您共享的错误中,payment.id为35。错误是,在shopping.views中没有名为payment_confirmation的方法,或者该方法不接受单个int作为参数

您没有在视图文件中共享付款确认方法,因此这似乎是问题所在。您需要添加:

def payment_confirmation(payment_id):
 #do stuff

欢迎光临。

嗨,杰里米!我看到了这个方法,但是错误还在继续。def payment_confirmation(请求,id):return HttpResponse(“aguarde o pagamento,obrigado!”)
def payment_confirmation(payment_id):
 #do stuff