Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.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中另一个已安装应用程序的URL标记_Python_Django - Fatal编程技术网

Python 链接Django中另一个已安装应用程序的URL标记

Python 链接Django中另一个已安装应用程序的URL标记,python,django,Python,Django,在Python 3.8上运行Django 3.0.7 我正在应用程序中登录Django项目:SupplierPortal,并尝试将导航按钮链接到cashmgnnt 下面是base.py中的href: 以下是URL.py: urlpatterns = [ path('customer/customerdetail/<int:pk>', views.AppCustomerCstDetailView.as_view(), name='customer-detail'), ] 加

在Python 3.8上运行Django 3.0.7

我正在应用程序中登录Django项目:
SupplierPortal
,并尝试将导航按钮链接到
cashmgnnt

下面是base.py中的href:

  • 以下是URL.py:

    urlpatterns = [
        path('customer/customerdetail/<int:pk>', views.AppCustomerCstDetailView.as_view(), name='customer-detail'),
    ]
    
    加载时,我遇到以下错误:

    Reverse for 'customer-detail' with no arguments not found. 1 pattern(s) tried: ['customer/customerdetail/(?P<pk>[0-9]+)$']
    
    未找到参数的“客户详细信息”的反向。尝试了1个模式:[“客户/客户详细信息/(?P[0-9]+)$”]
    您正在urlpattern中接受一个int参数

    urlpatterns = [
        path('customer/customerdetail/<int:pk>', views.AppCustomerCstDetailView.as_view(),name='customer-detail'),
    ]
    
    反向功能应如下所示

    reverse('customer-detail', args=[int(self.id)])
    

    尝试删除视图中的
    pk=
    ,使其成为
  • 这是解决方案的一部分!我还注意到,在我呈现页面的视图中,由于某个类型,ID没有被填充!愚蠢的胖手指!!谢谢,否则我永远不会看到这个!
    class AppCustomerCstDetailView(generic.DetailView):
        model = AppCustomerCst
        paginate_by = 10
    
        def get_absolute_url(self):
            return reverse('customer-detail', args=[str(self.id)])
    
    reverse('customer-detail', args=[int(self.id)])