Django Likes // Learn to create an Ajax-powered Like Button
Why Stack Overflow recommends it
Stack Overflow users cite it as the tutorial they followed when building a Django Ajax like button, usually when they hit errors in their own implementation.
Recommended by 0 people across 0 different months, 2018 to 2021.
What it is
A 33-minute Django tutorial from CodingEntrepreneurs that builds a Facebook-style like button using Django, Django Rest Framework and jQuery Ajax. It focuses on setting up the Django backend to collect like data, and notes the approach works with other front ends too.
What people said
Cites Jay P. · 2018-04 · Stack Overflow · on “Django - get_redirect_url() causes Page not found (404)”
I'm trying to implement favorite feature so that user can choose favorite stores. I'm currently referencing the video [this video] and stuck with the beginning. When I try to move to the url [LINK] , it throws the error message saying No Store matches the given query. So, I guess self.kwargs.get("domainKey") this snippet seems to throw the error, but I don't know why. I'm not sure if I'm showing my codes enough, so please let me know I need to show more. models.py class Store(models.Model): ... domainKey = models.CharField(max_length=100) likes = models.ManyToManyField(settings.AUTH_USER_MODEL, blank=True) ... urls.py url(r'^(?P<store_domainKey>.*)/$', views.detail, name='detail'), url(r'^(?P<sto
Cites Iakovos Belonias · 2019-03 · Stack Overflow · on “Changes on model instance not shown in Tempalate”
You need to use ajax for the automate template update, otherwise you'll have to refresh each time [this video] Also add the never_cache decorator [LINK] In your view at views.py file from django.views.decorators.cache import never_cache @never_cache def yourView(...): .... or if you have a class based view from django.views.decorators.cache import never_cache class YourView(View): @never_cache def dispatch(self,request,*args,**kwargs): return super().dispatch(request,*args,**kwargs)
Cites KaNishk SiNghal · 2019-04 · Stack Overflow · on “ajax function not found”
Getting error TypeError: $.ajax is not a function , i was creating ajax powered like button following this youtube video [this video] site is django based my script is <script src=" [LINK] "></script> <script> $(document).ready(function(){ function updateText(btn, newCount, verb){ btn.text(newCount + " " + verb) } $(".like-btn").click(function(e){ e.preventDefault() var this_ = $(this) var likeUrl = this_.attr("data-href") var likeCount = parseInt(this_.attr("data-likes")) | 0 var addLike = likeCount + 1 var removeLike = likeCount - 1 if (likeUrl){ $.ajax({ url: likeUrl, method: "GET", data: {}, success: function(data){ console.log(data) var newLikes; if (data.liked){ updateText(this_, addLike, "
Cites Prateek Gautam · 2019-09 · Stack Overflow · on “OperationalError at /admin/blogapp/post/220/change/ no such table: blogapp_post_likes?”
I've made a django blog app and its working fine. Now I'm trying to add a like feature to the blogs by the users. I added a likes field in my Post model but as soon as I ran the makemigrations and migrations command and went into my django-admin and click on the Post model, I got this -no such table: blogapp_post_likes. I'm learning from this tutorial [this video] and he also did the same thing but his migrations worked. I've tried deleting the migrations folder from the project prior to the makemigrations and migration command but its not working. Here's my models.py file- from django.db import models from django.urls import reverse from django.utils import timezone from django.contrib.auth.mode
Cites Poornaka · 2021-01 · Stack Overflow · on “An operational error when making django AJAX likes”
This is the error that I got. django.db.utils.OperationalError: no such table: photos_post_likes I was following this video to create a like button. [this video] By then I had already created the model (Post). Just when I added a new line (likes) in models.py and ran makemigrations, it migrated without any problem. But, when I ran migrate this error appeared. Here is the models.py file from django.db import models from django.utils import timezone from django.urls import reverse from django.contrib.auth.models import User from PIL import Image class Post(models.Model): date_shared = models.DateTimeField(default=timezone.now) caption = models.TextField(max_length=50) user = models.ForeignKey(User,