我想问你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"
在名称为(urls.py)的文件中
path('AuthorView/<slug>/',AuthorView.as_view(),name="AuthorView"),
并在文件中(Authorview.html)
{% extends 'base.html' %}
{% block content %}
<div align="center">
{{ authorview.author.name }}
</div>
{% endblock %}
ValueError
来了,他说:
invalid literal for int() with base 10: '<name_of_author>'
我想问一下<name_of_author>
的价值是什么?
以及如何解决问题?