Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Bugs & Fixes 2 years ago
Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I am trying to edit an html page so a logged in user can favorite a video.id
video.id
Here is the .html file
<td> <form method='POST' action="{% url 'foobar:favourite_post' video.id %}"> {% csrf_token %} <input type='hidden' name='video' value={{ video.id }}> <button type='submit'>Bookmarkbutton> form> td>
Here is the urls.py file
app_name = 'foobar' urlpatterns = [ path('', views.f_ListView.as_view(), name='overview'), path('/', views.f_DetailView.as_view(), name='detailview'), path('/favourite_post/', views.favourite_post, name='favourite_post'), ]
Here is the view.py file
def favourite_post(request, fav_id): video = get_object_or_404(Video, id=fav_id) if request.method == 'POST': #Then add this video to s://forum.tuteehub.com/tag/user">users' favourite video. return render(request, 'foobar/%s' % fav_id)
How to edit the views.py file so it is registered in the database that the user has favorited this video ?
Here is the models.py file
from django.contrib.auth.models import AbstractUser class ProjectUser(AbstractUser): def __str__(self): return self.email class Video(models.Model): name = models.CharField(max_length=255), videos://forum.tuteehub.com/tag/file">file = models.FileField(upload_to="static/videos/"), favourite = models.ManyToManyField(ProjectUser, related_name="fav_videos", blank=True)
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.