Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

254
Views
how can i create a table entry in django views

I want to make a system of likes on the site, and I need to create an entry in the table on the button. When a person clicks on like, the table writes row 1 and when dislike 0

views.py

def forum(requset):
      model = Quetions.objects.all()
      answer = Answer.objects.all()
      count = Answer.objects.all().count()
count_answer = Quetions.objects.all().count() 
paginator = Paginator(model, 1) # Show 25 contacts per page.
page_number = requset.GET.get('page')
question_id = requset.GET.get('id',False)
page_obj = paginator.get_page(page_number)
requestanswer = requset.GET.get('id',False)
like_disli = like.objects.filter(like_dislike = "1").count()
dislike = like.objects.filter(like_dislike = "0").count()
createlike = 
objects = {
    'model': page_obj,
    'answer':answer,
    'count':count,
    'count_question':count_answer,
    'page_obj':page_obj,
    'question':question_id,
    'id':model,
    'request':requestanswer,
    'like':like_disli,
    'dislike':dislike,
    'createlike':createlike,
    }
return render(requset,'forum.html',objects)

forum.html

 <span>
            <i class="fas fa-thumbs-up" style="color: blue;margin-right: 5px;" onclick="incrementClick()"></i>{{like}}<i class="fas fa-thumbs-down" style="color: red;margin-right: 5px;margin-left: 10px;" onclick="dislikeclick()"></i>{{dislike}} 
        </span>
{% block js %}
<script>
var a = "{{createlike}}"
function incrementClick() {
    a
}
function dislikeclick() {
    dislikedisplay(++dislikecounter);
}
function updateDisplay(val) {
    document.getElementById("counter-label").innerHTML = val;
}
function dislikedisplay(val){
    document.getElementById("counter").innerHTML = val
}
</script> 
{% endblock js %}

tell me how to do it???

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!