def gallery_async(request):
 media_type = request.GET.get('type', 'image')
 term = request.GET.get('q')
 media_locale = request.GET.get('locale', settings.WIKI_DEFAULT_LANGUAGE)
 if (media_type == 'image'):
  media_qs = Image.objects
 elif (media_type == 'video'):
  media_qs = Video.objects
 else:
  raise Http404
 media_qs = media_qs.filter(locale=media_locale)
 if term:
  media_qs = media_qs.filter((Q(title__icontains=term) | Q(description__icontains=term)))
 media = paginate(request, media_qs, per_page=ITEMS_PER_PAGE)
 return render(request, 'gallery/includes/media_list.html', {'media_list': media})

def gallery_async ( request ) : media_type = request . GET . get ( 'type' , 'image' ) term = request . GET . get ( 'q' ) media_locale = request . GET . get ( 'locale' , settings . WIKI_DEFAULT_LANGUAGE ) if ( media_type == 'image' ) : media_qs = Image . objects elif ( media_type == 'video' ) : media_qs = Video . objects else : raise Http404 media_qs = media_qs . filter ( locale = media_locale ) if term : media_qs = media_qs . filter ( ( Q ( title__icontains = term ) | Q ( description__icontains = term ) ) ) media = paginate ( request , media_qs , per_page = ITEMS_PER_PAGE ) return render ( request , 'gallery/includes/media_list.html' , { 'media_list' : media } )
ajax endpoint to media gallery .