我是 Django 新手,不明白什么是 pk 或 slug。到底是怎么回事?模型.py:class School(models.Model): name = models.CharField(max_length=256) principal = models.CharField(max_length=256) location = models.CharField(max_length=256) def __str__(self): return self.name模板页面:<a class="navbar-brand" href="{% url 'basic_app:list'%}">Schools</a>网址.py:path('',views.SchoolDetailView.as_view(),name='list'),视图.py:class SchoolDetailView(DetailView): context_object_name = 'school_detail' model = models.School template_name = 'basic_app/school_detail.html'
添加回答
举报
0/150
提交
取消