URL passes parameter in my Django project
I am just a Django beginner, these days I have followed mooc to learn Django, I wanted to create my first website but something went wrong and I cannot figure it out. I wanted to write a regex with the 'cate' parameter in URLS.py to match the video function in my view.py, judging by whether the "cate" eequals are "editors", if so it will return data with the attribute "editors_choice". However, I didn't find that it never changes, so I typed "cate" in view.py and found it always "No" and I still don't know why.
Below is my code:
def video(request, cate=None):
print(cate)
context = {} =
if cate is None:
video_list = Video.objects.all()
if cate == 'editors':
video_list = Video.objects.filter(editors_choices=True)
else:
video_list = Video.objects.all()
page_robot = Paginator(video_list, 16)
page_num = request.GET.get('page')
try:
video_list = page_robot.page(page_num)
except EmptyPage:
video_list = page_robot.page(page_robot.num_pages) # raise HTTP404("Empty")
except PageNotAnInteger:
video_list = page_robot.page(1)
context['video_list'] = video_list
return render(request, 'ten_movie.html', context)
+3
source to share