请各路大神指点,不知道具体是怎么错了,解决不了,具体代码如下:
from django.shortcuts import render
from .models import Topic
Create your views here.
def index(request):
“”“学习笔记的主页”""
return render(request, ‘learning_logs/index.html’)
def topic(request, topic_id):
“”“显示单个主题及其所有的条目”""
topic = Topic.objects.get(self,id=topic_id)
entries = topic.entry_set.order_by(’-date_added’)
context = {‘topic’: topic,‘entries’: entries}
return render(request, ‘learning_logs/topic.html’,context)
报错:
“D:\software\python\PyCharm 2019.2.4\bin\runnerw64.exe” D:\learning_log\ll_env\Scripts\python.exe D:/learning_log/manage.py runserver 8000
Performing system checks…
Watching for file changes with StatReloader
System check identified no issues (0 silenced).
November 21, 2019 - 14:09:10
Django version 2.2.7, using settings ‘learning_log.settings’
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[21/Nov/2019 14:09:12] “GET / HTTP/1.1” 200 181
Internal Server Error: /topics/
Traceback (most recent call last):
File “D:\learning_log\ll_env\lib\site-packages\django\core\handlers\exception.py”, line 34, in inner
response = get_response(request)
File “D:\learning_log\ll_env\lib\site-packages\django\core\handlers\base.py”, line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File “D:\learning_log\ll_env\lib\site-packages\django\core\handlers\base.py”, line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
TypeError: topic() missing 1 required positional argument: ‘topic_id’
[21/Nov/2019 14:09:14] “GET /topics/ HTTP/1.1” 500 64059