我想问一下Django 2.0.2中的值类型,我有代码 在名为(models.py)的文件中
class AutherDetalis(models.Model):
author = models.ForeignKey(Author,on_delete=models.PROTECT)
post = models.ForeignKey(Post,on_delete=models.PROTECT)
def __str__(self):
return "{} - {}".format(self.author,self.post)
在名为(views.py)的文件中
class AuthorView(DetailView):
model = AutherDetalis
template_name = "AuthorView.html"
context_object_name = "authorview"
slug_field = "author"
在名为(url.py)的文件中
path('AuthorView/<slug>/',AuthorView.as_view(),name="AuthorView"),
和文件(Authorview.html)
{% extends 'base.html' %}
{% block content %}
<div align="center">
{{ authorview.author.name }}
</div>
{% endblock %}
他说:
invalid literal for int() with base 10: '<name_of_author>'
我想问一下<name_of_author>
的值是什么?
我怎样才能解决这个问题
目前没有回答
相关问题 更多 >
编程相关推荐