[Answer]-In django which is the best way to make a slideshow of background images?

1๐Ÿ‘

i would render all images to frontend and slide with jquery.

something like: (you need to adjust variables names accordingly, these are almost pseudo ones)

{% for im in all_images %}
   <img src="im.url" id="im_{{ forloop.counter }}" />
{% endfor %}

jquery:

var random_im_id = Math.floor(Math.random() * 3) + 1; // random number between 1 - 3
var background_image = 'url(' + $('#im_' + random_im_id).attr('src') +  ')';

$('body').css('background-image', background_image);
๐Ÿ‘คdoniyor

Leave a comment