user3484272
user3484272

Reputation: 11

How to add a background imageas static image in django

please help me with this. I have an image slider. it shoud add like this bellow..

<div class="slider-item" style="background-image: url('img/hero_2.jpg');">
        <div class="container">
          <div class="row slider-text align-items-center justify-content-center">
            <div class="col-md-8 text-center col-sm-12 element-animate">
              <h1>Delecious Food</h1>
              <p class="mb-5">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Commodi unde impedit, necessitatibus, soluta sit quam minima expedita atque corrupti reiciendis.</p>
              <p><a href="#" class="btn btn-white btn-outline-white">Get Started</a></p>
            </div>
          </div>
        </div>

      </div>

Not working like these ways

<div class="slider-item" style="background-image: url({%static'/img/hero_1.jpg'%});">
or

  <div class="slider-item" style="background-image: url{%static'/img/hero_1.jpg'%}">

I don't want to add like an img tag like this way " <img src="{% static '/img/hero_2.jpg' %}" />" 
I am using Django latest version with python 3.0 all are latest version

Thank you

Upvotes: 0

Views: 58

Answers (1)

briyan hingrajiya
briyan hingrajiya

Reputation: 24

Update your settings.py file like given below and run command "python manage.py collectstatic"enter image description here

Upvotes: 1

Related Questions