You have shared very little which means I will make some assumptions about 
your specific implementation need. I see you have a Book model that has 
total number of books. I imagine you want to *minus* or *add *to the total 
number of books every time a book is borrowed or new books are added to the 
system.

Depending on requirements, you could:

   - Use what is called a calculated field in the model 
   - Calculate the remaining the number of books in the views whenever an 
   event occurs (one that affects the total of numbers of books), say a 
   student borrowing a book. 

On Saturday, 30 April 2022 at 21:48:15 UTC+3 narsh...@gmail.com wrote:

> In a book bank made in Django, I want to show only the remaining books 
> instead of all books. This I want to upgrade in the code below????
>
>
> def view_books_student(request): 
>     books = Book.objects.all() 
>     return render(request, "view_books_student.html", {'books':books})
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0198ef2c-379e-493f-9dab-d11871dda892n%40googlegroups.com.

Reply via email to