Advertisement
horozov86

Exercises: Working with Queries in Django

Nov 10th, 2023
969
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. # 1.    Artwork Gallery
  2.  
  3. def show_highest_rated_art():
  4.     best_art = ArtworkGallery.objects.order_by("-rating", "id").first()
  5.    
  6.     retrun f"{best_art.art_name} is the highest-rated art with {best_art.rating} rating!"
  7.    
  8.    
  9. def bulk_create_arts(first_art, second_art):
  10.     ArtworkGallery.objects.bulk_create([first_art, second_art])
  11.  
  12.  
  13. def delete_negative_rated_arts():
  14.     ArtworkGallery.objects.filter(rating__lt=0).delete()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement