Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // the function of searching by adding arguments of 'keywords' in url, how to pass another parameter, such as user's id in that url? They are not request_url = "user<int:pk>/course/list?keywords="+keywords or request_url = "request.user.pk/course/list?keywords="+keywords........
- // views.py the function of searching
- search_keywords = request.GET.get('keywords', '')
- if search_keywords:
- all_courses = all_courses.filter(Q(name__icontains=search_keywords) | Q(desc__icontains=search_keywords) | Q(
- detail__icontains=search_keywords))
- // common.js function of searching
- function search_click(){
- var type = $('#jsSelectOption').attr('data-value'),
- keywords = $('#search_keywords').val(),
- request_url = '';
- if(keywords == ""){
- return
- }
- if(type == "course"){
- request_url = "/course/list?keywords="+keywords
- }else if(type == "teacher"){
- request_url = "/org/teacher/list?keywords="+keywords
- }else if(type == "org"){
- request_url = "/org/list?keywords="+keywords
- }
- window.location.href = request_url
- }
Advertisement
Add Comment
Please, Sign In to add comment