#StackBounty: #javascript #python #html #css #django Favorite system in Django

Bounty: 50

Image

enter image description here

$(document).ready(function(){
    $(".like").click(function(){
        $(this).toggleClass("heart");
    });
});
.like {
  padding-right: 6px;
  color: #00000030;
  font-size: 1.6em;
  padding-top: 5px;
  animation: like 0.5s linear;
}

.heart {
  color: #FF0000;
  animation: heart 0.5s linear;
}
{% for m in musicl %}
  <div class="card">
        <div class="top">
          <div class="year">{{m.Year}}</div>
          <span class="like"><i class="fa fa-heart"></i></span>
        </div>

        <div class="middle">
          <a href="https://google.com" id="link" target="_blank">
            <div class="img-container"><img src="{{ m.Image.url }}"></div>
          </a>
        </div>

        <a href="https://google.com" id="link" target="_blank">
          <div class="bottom">
            <div class="title">{{m.Name}}</div>
            <div class="genre">{{m.Genre}}</div>
          </div>
        </a>
  </div>
{% endfor %}

models.py

class Music(models.Model):
    Name = models.CharField(max_length=100, blank=False)
    Year = models.IntegerField(('year'), choices=YEAR_CHOICES, default=datetime.datetime.now().year)
    Genre = MultiSelectField(choices=GENRE_CHOICES)
    Image = models.ImageField(blank=False, null=True)

    def __str__(self):
        return self.Name

Views.py

def home(request):
    return render(request, template_name='main/home.html', context={"musicl": Music.objects.all})


def wishlist(request, id):
    pass

How do I connect the User model to this favorite system and keep track of the favorite list in a view function(wishlist), in other words when someone clicks on the fav icon, I want that specific card to be saved to the wishlist view corresponding to that User model


Get this bounty!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.