▶️ Watch Entire Django Wednesdays Playlist ✅ Subscribe To My KZbin Channel: bit.ly/35Xo9jD bit.ly/2IGzvOR ▶️ See More At: ✅ Join My Facebook Group: Codemy.com bit.ly/2GFmOBz ▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt! Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN ▶️ Get The Code bit.ly/3sJpeV6
@jasondavis68502 жыл бұрын
Thanks again for the series. Here's a way to send checked and unchecked values to the database. I'm only a newb to python/django so it took me a lot longer than 5 minutes. Enjoy! def admin_approval(request): event_list = Event.objects.all().order_by('-event_date') events_all = Event.objects.all() events_all_ids = [] for i in range(0, len(events_all), 1): events_all_ids.append(str(events_all[i].id)) if request.user.is_superuser: if request.method == 'POST': id_list_true = request.POST.getlist('boxes') for x in id_list_true: Event.objects.filter(pk=int(x)).update(approved=True) id_set_false = set(events_all_ids) - set(id_list_true) id_list_false = list(id_set_false) for y in id_list_false: Event.objects.filter(pk=int(y)).update(approved=False) messages.success(request, ('Event List Approval has been updated')) return redirect('events_list') else: return render(request, 'events/admin_approval.html', { 'event_list': event_list }) else: messages.success(request, ('You are not authorized to view this page.')) return redirect('home')
@mateuszbaszkowski14292 жыл бұрын
Man, youre doing great job. I was just struggling with checkboxes on my very first app. Thanks a million.
@Codemycom2 жыл бұрын
Happy to help!
@aldya15322 жыл бұрын
Very simple and nice solution! Thanks a lot! And thanks for your wonderful English)
@Codemycom2 жыл бұрын
Welcome
@hemantsah85672 жыл бұрын
I spent 2 hours working on this kind of issue, thanks to your video,
@stardust_dweller Жыл бұрын
This helped me so much! Thank you!
@Codemycom Жыл бұрын
Welcome!
@prakalpitneupane92532 жыл бұрын
I needed to do the same, your video saved my day 😃
@Codemycom2 жыл бұрын
awesome
@skyline-wd3gr2 жыл бұрын
You are my favorite KZbinr
@Codemycom2 жыл бұрын
Thanks!
@skyline-wd3gr2 жыл бұрын
I have implemented many things in my python project by watching your videos
@Codemycom2 жыл бұрын
Glad to hear it!
@kodeypatterson89732 жыл бұрын
Great video, thanks a lot. I've been following for a while
@Codemycom2 жыл бұрын
Thanks for watching!
@eesakamaldien19172 жыл бұрын
I love your videos always the best
@Codemycom2 жыл бұрын
Thanks!
@darthvader662 жыл бұрын
Nice video and great explanation! Is it better to have Event.objects.filter(pk__in=id_list).update(approved=True) instead of hitting the database n times seperately in the for loop?
@anilkumar-ug3yd2 жыл бұрын
If you have lots of rows and u want to use pagination filter and builk update and delete by checkbox. what should be done ?
@ZAYN_ONE_DIRECTION2 жыл бұрын
Sir you had a video on adding images to buttons in tkinter. Does the same method shown in the video also work for buttons in a canvas?
@Codemycom2 жыл бұрын
Try it and see
@thomasnowak98252 жыл бұрын
For this, is it worth covering checking dates and times of events? For example, if someone entered an event and then someone else entered an event with the same date and time, it would be cool to reject the last one saying there is already an event for that date and time.
@Codemycom2 жыл бұрын
Why can’t there be two events at the same time?
@thomziq2 жыл бұрын
Hey:) Is there a possibility to add Matplotlib graphs to Django? Maybe some stats about Events?
@Codemycom2 жыл бұрын
Probably, though I don't have any videos on it
@Adrian-mh8op2 жыл бұрын
Would you know how to create leaderboards in python. Do you have any videos for that
@Codemycom2 жыл бұрын
Sorry, don't know what you mean by leaderboards
@Adrian-mh8op2 жыл бұрын
I’m doing a python flashcard app, it tree ore where users enter details and it gets submitted into a database. But I want to do a leaderboard which ranks the most correct answers from users. Do u have any vids on that or know how to begin doing that
@Codemycom2 жыл бұрын
I have tons of videos about getting data from a database and displaying it on a screen. Nothing specific about leaderboards, but it would be trivial to order by whatever.
@tonystark33992 жыл бұрын
Sir can you please make a video on making scientific calculator with kivy ?
@Codemycom2 жыл бұрын
I've already done a calculator with kivy. Just add the scientific functions you want.
@sinacoder2 жыл бұрын
💻☕🍔🍟
@Codemycom2 жыл бұрын
:-)
@hiwab412 жыл бұрын
First
@Codemycom2 жыл бұрын
Nice!
@tariqjahhaf7113 Жыл бұрын
Your efforts are honorable.. Thanks alot.. and for the checkbox issue you are not updating the unchecked Events, This is how I solved that: events = Event.objects.all().order_by('-date', 'name') context = { 'events': events } all_true_list = [] for event in events: if event.approved: all_true_list.append(str(event.id)) if request.user.is_superuser: if request.method == 'POST': checked_id_list = request.POST.getlist('boxes') for item in all_true_list: if item not in checked_id_list: Event.objects.filter(pk=int(item)).update(approved=False) else: pass for item in checked_id_list: Event.objects.filter(pk=int(item)).update(approved=True) messages.success(request, "Events updated") return redirect('events_list.html') else: return render(request, 'events_list.html', context) else: messages.success(request, "You are not authorized to view this page") return redirect('home')