django-models - 我在 django 的动态 urls 系统中有问题
问题描述
我一直在关注 youtube 上关于构建某种项目的其他教程。几天来试图找到问题的解决方案
我尝试使用'str'和'int'
from django.urls import path
from . import views
urlpatterns = [
path('', views.home),
path('products/', views.products),
path('customer/<int:my_id>/', views.customer),
]
这是我在views.py中的代码
def customer(request, my_id):
customer = Customer.objects.get(id=my_id)
orders = customer.order_set.all()
context = {'customer': customer, 'orders': orders}
return render(request, 'accounts/customer.htm', context)
请帮忙
解决方案
推荐阅读
- json - Kafka 流 API - 反序列化动态生成的 JSON
- c++ - 使用 shared_ptr 的矩阵类内容?
- caching - 直写和直读缓存
- spring - 从 application.properties 读取属性的最佳方法是什么?
- powerbi - DAX - 添加具有最常见值的列
- c# - 如何替换括号中的字段
- flutter - 一个 RenderFlex 在右侧溢出了 74 个像素
- javascript - 获取变异类名的索引
- css - 在 rails 5 中未使用具有不同布局的 redirect_to 加载资产
- android - Flutter 中即使应用已断开连接,如何查看日志?