I have a simple model in Django for a Library Manager. Inside there are 3 models. One to record all the books, another to issue the books and the last one to return the issued books. I already have the relationships done, but the problem arose when I wanted to issue a book. If a book is issued it should no longer be in the book records but rather be in the issued records. And when it is being returned it should go through the return class and get added to the book record. My question is "is it possible to move books in my case from on class to another?"
CodePudding user response:
Unfortunately, I believe you can't do that without deleting the object.
Why don't you just use only one Book model? Then you can define a status for this book, like:
issued = models.BooleanField(default=False)
Set this to True when the book has been issued, later on, you can use django orm to filter for issued books only like:
Books.objects.filter(issued=True)
If you still have any doubts, feel free to make another question. If you found this helpful, dont forget to upvote this answer.
