但是如下图中新增客户和编辑客户视图重复内容太多了,所以我想做一个整合。否则到时候要改代码的话要改很多,不方便。
(1)crm/urls.py中:两个url对应一个视图函数
from django.conf.urls import url,includefrom crm import viewsurlpatterns = [ url(r‘^customer_list/‘,views.customer_list,name=‘customer‘),# 增加客户 url(r‘customer/add/‘, views.customer, name=‘add_customer‘), # 编辑客户 url(r‘customer/edit/(\d+)‘, views.customer, name=‘edit_customer‘),]
(2)views.py中:
(3)templates/crm/customer.html中:
原文地址:https://www.cnblogs.com/dbslinux/p/12048501.html
时间: 2024-11-08 05:02:51