{"id":20469089,"url":"https://github.com/ghosts6/library_management_system","last_synced_at":"2026-04-02T03:08:07.276Z","repository":{"id":226930454,"uuid":"769818399","full_name":"Ghosts6/Library_management_system","owner":"Ghosts6","description":"Library management system from basic to advacne write with languages like bash,c,c++,python and js ","archived":false,"fork":false,"pushed_at":"2025-12-11T23:04:11.000Z","size":7540,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-13T04:42:38.423Z","etag":null,"topics":["bash","c","cpp","django","django-orm","django-rest-framework","html-css-javascript","javascript","library-management-system","postgresql","python3","tailwind"],"latest_commit_sha":null,"homepage":"","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ghosts6.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-10T06:24:09.000Z","updated_at":"2025-12-11T23:04:16.000Z","dependencies_parsed_at":"2024-03-10T17:39:01.234Z","dependency_job_id":null,"html_url":"https://github.com/Ghosts6/Library_management_system","commit_stats":null,"previous_names":["ghosts6/library_management_system"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Ghosts6/Library_management_system","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghosts6%2FLibrary_management_system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghosts6%2FLibrary_management_system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghosts6%2FLibrary_management_system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghosts6%2FLibrary_management_system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ghosts6","download_url":"https://codeload.github.com/Ghosts6/Library_management_system/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghosts6%2FLibrary_management_system/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31294851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T01:43:37.129Z","status":"online","status_checked_at":"2026-04-02T02:00:08.535Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","c","cpp","django","django-orm","django-rest-framework","html-css-javascript","javascript","library-management-system","postgresql","python3","tailwind"],"created_at":"2024-11-15T14:07:56.005Z","updated_at":"2026-04-02T03:08:07.253Z","avatar_url":"https://github.com/Ghosts6.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"![baner](https://github.com/Ghosts6/Local-website/blob/main/img/Baner.png)\n\n# 📖Library Management system:\n\nThis repository is dedicated to hosting programs written in languages such as C, C++, Bash, JavaScript, and Python, writed for library management systems. The projects within explore difference data modeling techniques, providing discussions on various methods employed for efficient data storage and retrieval.\n\n# 📏Data Modeling:\n\n#Introduction:\n\nData modeling is a critical aspect of software development, influencing how information and data is structured, stored, and accessed.so in this repo we used different method of data modeling to store data including Object-Oriented Programming (OOP),data structures, files,models and databases.\n\n#1.OOP Attributes:\n\nWithin Object-Oriented Programming, attributes play a key role in encapsulating data. By associating data with objects and their behaviors, OOP provides a modular and organized approach to data modeling. However, the challenge lies in maintaining data consistency across different objects and ensuring proper encapsulation.oop as a one of data modeling method used to store data in our library.cpp program:\n```c++\n#include \u003ciostream\u003e\n#include \u003cstring\u003e\n#include \u003cstdio.h\u003e\n#include \u003csstream\u003e\n#include \u003ccstdlib\u003e\nusing namespace std;\n\n#define max_book 200\n\nclass LibBooks{\n    public:\n    string name;\n    string author;\n    string genre;\n    int edition;\n    int publish_date;\n};\n\nclass Info:public LibBooks{\n    public:\n    class LibBooks books[max_book];\n    int book_numbers;\n};\n\nvoid new_book(class Info *object,string name,string author,string genre,int edition,int publish_age);\nvoid book_list(class Info object);\nvoid search_book(class Info object,string name);\nvoid clear();\n\nint main(){\n    Info object;\n    object.book_numbers = 0;\n    char choice,choice_2;\n    label1:\n    label2:\n    cout\u003c\u003c'\\t'\u003c\u003c\"---welcome to our program---\"\u003c\u003cendl;\n    cout\u003c\u003c\"1. Add new book\"\u003c\u003cendl;\n    cout\u003c\u003c\"2. Display books list\"\u003c\u003cendl;\n    cout\u003c\u003c\"3. search for book\"\u003c\u003cendl;\n    cout\u003c\u003c\"4. Exit program\"\u003c\u003cendl;\n    cin\u003e\u003echoice;\n    switch (choice) {\n        case '1':\n        clear();\n        cout\u003c\u003c\"Adding new book\"\u003c\u003cendl;\n        {\n        string name;\n        string author;\n        string genre;\n        int edition;\n        int publish_year;\n        cout\u003c\u003c\"Enter name of book:\"\u003c\u003cendl;\n        cin\u003e\u003ename;\n        cout\u003c\u003c\"Enter author name:\"\u003c\u003cendl;\n        cin\u003e\u003eauthor;\n        cout\u003c\u003c\"Enter genre:\"\u003c\u003cendl;\n        cin\u003e\u003egenre;\n        cout\u003c\u003c\"Enter edition number :\"\u003c\u003cendl;\n        cin\u003e\u003eedition;\n        cout\u003c\u003c\"Enter date of publish\"\u003c\u003cendl;\n        cin\u003e\u003epublish_year;\n        new_book(\u0026object,name,author,genre,edition,publish_year);\n        }\n        break;\n        case '2':\n        clear();\n        cout\u003c\u003c\"Displaying book list\"\u003c\u003cendl;\n        book_list(object);\n        break;\n        case '3':\n        clear();\n        cout\u003c\u003c\"Searching for book\"\u003c\u003cendl;\n        {\n        string search_name;\n        cout\u003c\u003c\"Enter book name for search:\"\u003c\u003cendl;\n        cin\u003e\u003esearch_name;\n        search_book(object,search_name);\n        }\n        break;\n        case '4':\n        clear();\n        cout\u003c\u003c\"Exit\"\u003c\u003cendl;\n        return 0;\n        default :\n        cout\u003c\u003c\"wrong choice please try again\"\u003c\u003cendl;\n        goto label1;\n    }\n    cout\u003c\u003c\"Do you want to continue?(y/n)\"\u003c\u003cendl;\n    cin\u003e\u003echoice_2;\n    if (choice_2 == 'y' || choice_2 == 'Y') {\n    \n        goto label2;\n    }else if(choice_2 == 'n' || choice_2 == 'N'){\n        cout\u003c\u003c\"End of program\"\u003c\u003cendl;\n    }    \n  return 0;     \n}\n\nvoid new_book(class Info *object, string name, string author, string genre, int edition, int publish_year) {\n    if (object-\u003ebook_numbers \u003c max_book) {\n        class LibBooks new_book;\n        new_book.name = name;\n        new_book.author = author;\n        new_book.genre = genre;\n        new_book.edition = edition;\n        new_book.publish_date = publish_year;\n        object-\u003ebooks[object-\u003ebook_numbers] = new_book;\n        object-\u003ebook_numbers++;\n        cout \u003c\u003c \"Book added successfully\" \u003c\u003c endl;\n    } else {\n        cout \u003c\u003c \"Library is full, cannot add more books\" \u003c\u003c endl;\n    }\n}\n\nvoid book_list(class Info object) {\n    for (int i = 0; i \u003c object.book_numbers; i++) {\n        cout \u003c\u003c \"Name: \" \u003c\u003c object.books[i].name \u003c\u003c '\\n'\n             \u003c\u003c \"Author: \" \u003c\u003c object.books[i].author \u003c\u003c '\\n'\n             \u003c\u003c \"Genre: \" \u003c\u003c object.books[i].genre \u003c\u003c '\\n'\n             \u003c\u003c \"Editions: \" \u003c\u003c object.books[i].edition \u003c\u003c '\\n'\n             \u003c\u003c \"Publish date: \" \u003c\u003c object.books[i].publish_date \u003c\u003c endl;\n    }\n}\n\nvoid search_book(class Info object, string name) {\n    cout \u003c\u003c \"Search result ...\" \u003c\u003c endl;\n    for (int i = 0; i \u003c object.book_numbers; i++) {\n        if (object.books[i].name == name) {\n            cout \u003c\u003c \"Name: \" \u003c\u003c object.books[i].name \u003c\u003c '\\n'\n                 \u003c\u003c \"Author: \" \u003c\u003c object.books[i].author \u003c\u003c '\\n'\n                 \u003c\u003c \"Genre: \" \u003c\u003c object.books[i].genre \u003c\u003c '\\n'\n                 \u003c\u003c \"Editions: \" \u003c\u003c object.books[i].edition \u003c\u003c '\\n'\n                 \u003c\u003c \"Publish date: \" \u003c\u003c object.books[i].publish_date \u003c\u003c endl;\n        }\n    }\n    cout\u003c\u003c\"book not found\"\u003c\u003cendl;\n}\n\nvoid clear(){\n    const char* clearCommand = nullptr;\n    #ifdef _WIN32\n        clearCommand =\"cls\";\n    #elif __linux__\n        clearCommand =\"clear\";\n    #else    \n        cout\u003c\u003c\"Unsupported operating system.\"\u003c\u003cendl;\n        return;\n    #endif\n    \n    int result = system(clearCommand);\n    if (result == 0) {\n        cout\u003c\u003c\"Command executed successfully.\"\u003c\u003cendl;\n    } else {\n        cout\u003c\u003c\"Command execution failed.\"\u003c\u003cendl;\n    }\n};\n```\n\n#2.Data Structures Attributes:\n\nData structures offer a versatile way to organize and store data. From arrays to linked lists, each structure has its unique advantages and trade-offs. Attributes inside data structures provide a foundation for efficient data access and manipulation, but the choice of structure must align with the specific requirements of the application.so data structure was another of our option to store data which we use it on library.c:\n```c\n#include \u003cstdio.h\u003e\n#include \u003cstring.h\u003e\n#include \u003cstdlib.h\u003e\n\n#define max_book 200\n\nstruct LibBooks{\n    char name[100];\n    char author[100];\n    char genre[100];\n    int edition;\n    int publish_date;\n};\n\nstruct Info{\n    struct LibBooks books[max_book];\n    int book_numbers;\n};\n\nvoid new_book(struct Info *object, const char *name, const char *author, const char *genre, int edition, int publish_date);\nvoid book_list(struct Info object);\nvoid search_book(struct Info object,const char *name);\nvoid clear();\n\nint main(){\n    struct Info object;\n    object.book_numbers = 0;\n    char choice,choice_2;\n    label1:\n    label2:\n    printf(\"\\t---welcome to our program---\\n\");\n    printf(\"1. Add new book\\n\");\n    printf(\"2. Display books list\\n\");\n    printf(\"3. search for book\\n\");\n    printf(\"4. Exit program\\n\");\n    scanf(\" %c\", \u0026choice);\n    switch (choice){\n    case '1':\n        clear();\n        printf(\"Adding new book\\n\");\n        {\n         char name[100];\n         char author[100];\n         char genre[100];\n         int edition;\n         int publish_date;\n         printf(\"Enter name of book:\\n\");\n         scanf(\" %s\", \u0026name);\n\n         printf(\"Enter author name:\\n\");\n         scanf(\" %s\", \u0026author);\n\n         printf(\"Enter genre:\\n\");\n         scanf(\" %s\", \u0026genre);\n\n         printf(\"Enter edition number :\\n\");\n         scanf(\" %d\", \u0026edition);\n\n         printf(\"Enter date of publish\\n\");\n         scanf(\" %d\", \u0026publish_date);\n\n         new_book(\u0026object,name,author,genre,edition,publish_date);\n        }\n        break;\n    case '2':\n        clear();\n        printf(\"Displaying book list\\n\");\n        book_list(object);\n        break;\n    case '3':\n        clear();\n        printf(\"Searching for book\\n\");\n        {\n         char search_name[100];\n         printf(\"Enter book name for search:\\n\");\n         scanf(\" %s\", \u0026search_name);\n         search_book(object,search_name);\n        }\n        break;\n    case '4':\n        clear();\n        printf(\"Exit\\n\");\n        return 0;\n        break;\n    default:\n        printf(\"wrong choice please try again\");\n        goto label1;\n        break;\n    }\n    printf(\"Do you want to continue?(y/n)\\n\");\n    scanf(\" %c\", \u0026choice_2);\n    if (choice_2 == 'y' || choice_2 == 'Y') {   \n        goto label2;\n    }else if(choice_2 == 'n' || choice_2 == 'N'){\n        printf(\"End of program\\n\");\n    }   \n  return 0;\n}\n\nvoid new_book(struct Info *object, const char *name, const char *author, const char *genre, int edition, int publish_date){\n    if(object-\u003ebook_numbers\u003cmax_book){\n        struct LibBooks new_book;\n        strcpy(new_book.name,name);\n        strcpy(new_book.author,author);\n        strcpy(new_book.genre,genre);\n        new_book.edition = edition;\n        new_book.publish_date = publish_date;\n        object-\u003ebooks[object-\u003ebook_numbers] = new_book;\n        object-\u003ebook_numbers++;\n        printf(\"Book added successfully\\n\");\n    }else{\n        printf(\"Library is full, cannot add more books\\n\");\n    }\n}\n\nvoid book_list(struct Info object){\n    for(int i=0; i \u003c object.book_numbers ;i++){\n        printf(\"%d. Name:%s,Author:%s,Genre:%s,Edition:%d,Publish_date:%d \\n\",\n               i + 1,\n               object.books[i].name,\n               object.books[i].author,\n               object.books[i].genre,\n               object.books[i].edition,\n               object.books[i].publish_date);\n    }\n}\n\nvoid search_book(struct Info object,const char *name){\n    printf(\"Search result ...\\n\");\n    for(int i=0;i \u003c object.book_numbers; i++){\n        if(strcmp(object.books[i].name,name)==0){\n        printf(\"%d. Name:%s,Author:%s,Genre:%s,Edition:%d,Publish_date:%d \\n\",\n               object.books[i].name,\n               object.books[i].author,\n               object.books[i].genre,\n               object.books[i].edition,\n               object.books[i].publish_date);\n        }\n    }\n    printf(\"Book not found\\n\");\n}\n\nvoid clear() {\n    const char* clearCommand = NULL;\n    #ifdef _WIN32\n        clearCommand =\"cls\";\n    #elif __linux__\n        clearCommand =\"clear\";\n    #else    \n        printf(\"Unsupported operating system.\\n\");\n        return;\n    #endif\n    \n    int result = system(clearCommand);\n    if (result == 0) {\n        printf(\"Command executed successfully.\\n\");\n    } else {\n        printf(\"Command execution failed.\\n\");\n    }\n}\n```\n\n#3. File-based Storage:\n\nStoring data in files is a traditional method with its own set of advantages and challenges. Files provide a simple and accessible means of data storage, but scalability and complexity can become issues as data volume grows. Exploring various file formats and organization strategies becomes critical in optimizing file-based data modeling.we used file-based method for couple of programs include library.py library.sh,and here we can take closer look to library.py:\n```python\nclass LibBooks:\n    def __init__(self, name, author, genre, edition, publish_date):\n        self.name = name\n        self.author = author\n        self.genre = genre\n        self.edition = edition\n        self.publish_date = publish_date\n\nclass Info:\n    def __init__(self):\n        self.books = []\n        self.book_numbers = 0\n\n    def add_book(self, book):\n        self.books.append(book)\n        self.book_numbers += 1\n\n    def display_books(self):\n        for i, book in enumerate(self.books, start=1):\n            print(f\"Book number {i}:\\n\"\n                  f\"Name: {book.name}\\n\"\n                  f\"Author: {book.author}\\n\"\n                  f\"Genre: {book.genre}\\n\"\n                  f\"Edition: {book.edition}\\n\"\n                  f\"Publish date: {book.publish_date}\\n\"\n                  \"--------------------------\")\n\n    def search_book(self, name):\n        found = False\n        for i, book in enumerate(self.books, start=1):\n            if book.name == name:\n                print(f\"Book found at position {i}:\\n\"\n                      f\"Name: {book.name}\\n\"\n                      f\"Author: {book.author}\\n\"\n                      f\"Genre: {book.genre}\\n\"\n                      f\"Edition: {book.edition}\\n\"\n                      f\"Publish date: {book.publish_date}\")\n                found = True\n        if not found:\n            print(\"Book not found.\")\n\n    def save_to_file(self):\n        with open(\"book_list.txt\", \"a\") as file:\n            for book in self.books:\n                file.write(f\"--------------------------\\n\"\n                           f\"{book.name}\\n\"\n                           f\"{book.author}\\n\"\n                           f\"{book.genre}\\n\"\n                           f\"{book.edition}\\n\"\n                           f\"{book.publish_date}\\n\")\n\ndef clear():\n    import os\n    os.system('cls' if os.name == 'nt' else 'clear')\n\ndef main():\n    object = Info()\n\n    while True:\n        print(\"\\t---welcome to our program---\")\n        print(\"1. Add new book\")\n        print(\"2. Display books list\")\n        print(\"3. Search for a book\")\n        print(\"4. Exit program\")\n\n        choice = input(\"Enter your choice: \")\n\n        if choice == '1':\n            clear()\n            print(\"Adding new book\")\n            name = input(\"Enter name of the book: \")\n            author = input(\"Enter author's name: \")\n            genre = input(\"Enter genre: \")\n            edition = input(\"Enter edition number: \")\n            publish_date = input(\"Enter date of publish: \")\n\n            new_book = LibBooks(name, author, genre, edition, publish_date)\n            object.add_book(new_book)\n            object.save_to_file()\n            print(\"Book added successfully\")\n\n        elif choice == '2':\n            clear()\n            print(\"Displaying book list\")\n            object.display_books()\n\n        elif choice == '3':\n            clear()\n            print(\"Searching for a book\")\n            search_name = input(\"Enter the book name for search: \")\n            object.search_book(search_name)\n\n        elif choice == '4':\n            clear()\n            print(\"Exit\")\n            break\n\n        else:\n            print(\"Wrong choice, please try again.\")\n\n        choice_2 = input(\"Do you want to continue? (y/n): \").lower()\n        if choice_2 != 'y':\n            print(\"End of program\")\n            break\n\nif __name__ == \"__main__\":\n    main()\n```  \n\n#4. Database Storage:\n\nDatabases are robust solutions for structured data storage, offering features like indexing, transactions, and query optimization. However, choosing the right database model—whether relational data base management system(rdbms) or  not relational data base management system(nrdbms) requires careful consideration of the application's needs. While databases are better in data retrieval and management, their setup and maintenance can be complex.so beacuse of features and advantage of data bases we use them on our complex program like library.js and django project,we also stored data on library_v2.py with data bases and connector:\n```python\nfrom sqlalchemy import create_engine, Column, Integer, String, Date\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nBase = declarative_base()\n\nclass Book(Base):\n    __tablename__ = 'book'\n\n    id = Column(Integer, primary_key=True)\n    bookName = Column(String, nullable=False)\n    publisher = Column(String)\n    genre = Column(String)\n    editionNumber = Column(Integer)\n    dateOfPublish = Column(Date)\n\nclass Info:\n    def __init__(self, session):\n        self.session = session\n\n    def add_book(self, book):\n        self.session.add(book)\n        self.session.commit()\n\n    def display_books(self):\n        books = self.session.query(Book).all()\n        for i, book in enumerate(books, start=1):\n            print(f\"Book number {i}:\\n\"\n                  f\"Name: {book.bookName}\\n\"\n                  f\"Publisher: {book.publisher}\\n\"\n                  f\"Genre: {book.genre}\\n\"\n                  f\"Edition: {book.editionNumber}\\n\"\n                  f\"Publish date: {book.dateOfPublish}\\n\"\n                  \"--------------------------\")\n\n    def search_book(self, name):\n        book = self.session.query(Book).filter_by(bookName=name).first()\n        if book:\n            print(f\"Book found:\\n\"\n                  f\"Name: {book.bookName}\\n\"\n                  f\"Publisher: {book.publisher}\\n\"\n                  f\"Genre: {book.genre}\\n\"\n                  f\"Edition: {book.editionNumber}\\n\"\n                  f\"Publish date: {book.dateOfPublish}\")\n        else:\n            print(\"Book not found.\")\n\ndef clear():\n    import os\n    os.system('cls' if os.name == 'nt' else 'clear')\n\ndef create_database():\n    engine = create_engine('sqlite:///book_database.db')\n    Base.metadata.create_all(engine)\n    return engine\n\ndef main():\n    engine = create_database()\n    Base.metadata.bind = engine\n    DBSession = sessionmaker(bind=engine)\n    session = DBSession()\n\n    info_object = Info(session)\n\n    while True:\n        print(\"\\t---welcome to our program---\")\n        print(\"1. Add new book\")\n        print(\"2. Display books list\")\n        print(\"3. Search for a book\")\n        print(\"4. Exit program\")\n\n        choice = input(\"Enter your choice: \")\n\n        if choice == '1':\n            clear()\n            print(\"Adding new book\")\n            name = input(\"Enter name of the book: \")\n            publisher = input(\"Enter publisher: \")\n            genre = input(\"Enter genre: \")\n            edition = int(input(\"Enter edition number: \"))\n            publish_date = input(\"Enter date of publish (YYYY-MM-DD): \")\n\n            new_book = Book(bookName=name, publisher=publisher, genre=genre,\n                            editionNumber=edition, dateOfPublish=publish_date)\n            info_object.add_book(new_book)\n            print(\"Book added successfully\")\n\n        elif choice == '2':\n            clear()\n            print(\"Displaying book list\")\n            info_object.display_books()\n\n        elif choice == '3':\n            clear()\n            print(\"Searching for a book\")\n            search_name = input(\"Enter the book name for search: \")\n            info_object.search_book(search_name)\n\n        elif choice == '4':\n            clear()\n            print(\"Exit\")\n            break\n\n        else:\n            print(\"Wrong choice, please try again.\")\n\n        choice_2 = input(\"Do you want to continue? (y/n): \").lower()\n        if choice_2 != 'y':\n            print(\"End of program\")\n            break\n\nif __name__ == \"__main__\":\n    main()   \n```\n\n#Conclusion:\n\nAll in all we can figure it out ,effective data modeling are depend on a thoughtful selection and integration of various storage methods. Whether utilizing oop attributes,data structures,file-based storage, or leaning on the power of databases, understanding the benefits and drawbacks of each approach is essential for designing a robust and reliable data storage solution. Balancing these considerations ensures that data modeling aligns with the specific requirements of the application, leading to efficient and effective data storage.\n\n# django:\n\nfor showing data modeling on real project and some more complicated program i also write this django project for library management system which here we can take look at apies and models:\n\napi:\n```python\nfrom django.shortcuts import render\nfrom django.http import JsonResponse\nfrom django.views.decorators.csrf import csrf_exempt\nfrom .models import Book\n\ndef home(request):\n    return render(request, 'home.html')\n\n@csrf_exempt\ndef add(request):\n    if request.method == 'POST':\n        name = request.POST.get('name')\n        author = request.POST.get('author')\n        genre = request.POST.get('genre')\n        edition_number = request.POST.get('edition_number')\n        publish_date = request.POST.get('publish_date')\n\n        try:\n            new_book = Book(\n                name=name,\n                author=author,\n                genre=genre,\n                edition_number=edition_number,\n                publish_date=publish_date\n            )\n            new_book.save()\n\n            return JsonResponse({'success': True})\n        except Exception as e:\n            print('Error:', str(e))\n            return JsonResponse({'success': False, 'error': 'Failed to save book'})\n\n    return JsonResponse({'success': False, 'error': 'Invalid method'})\n\ndef add_book(request):\n    return render(request, 'add.html')\n\ndef book_list(request):\n\n    books = Book.objects.all()\n\n    return render(request, 'book_list.html', {'books': books})\n\ndef search(request):\n    return render(request, 'search.html')\n\ndef search_book(request):\n    if request.method == 'GET':\n        book_name = request.GET.get('name')\n\n        try:\n            book = Book.objects.get(name__iexact=book_name)\n            return JsonResponse({'success': True, 'book': {\n                'name': book.name,\n                'author': book.author,\n                'genre': book.genre,\n                'edition_number': book.edition_number,\n                'publish_date': book.publish_date,\n            }})\n        except Book.DoesNotExist:\n            return JsonResponse({'success': False})\n\n    return JsonResponse({'success': False})\n```\nModels:\n```python\nfrom django.db import models\n\nclass Book(models.Model):\n    name = models.CharField(max_length=255, verbose_name='Book Name')\n    author = models.CharField(max_length=255, verbose_name='Book Author')\n    genre = models.CharField(max_length=100, verbose_name='Genre')\n    edition_number = models.IntegerField(verbose_name='Edition Number')\n    publish_date = models.DateField(verbose_name='Date of Publish')\n\n    def __str__(self):\n        return self.name\n\nclass Inventory(models.Model):\n    book = models.ForeignKey(Book, on_delete=models.CASCADE, verbose_name='Book')\n    book_number = models.CharField(max_length=20, unique=True, verbose_name='Book Number')\n    in_stock = models.PositiveIntegerField(default=0, verbose_name='In Stock')\n\n    def __str__(self):\n        return f\"{self.book.name} - {self.book_number}\"\n```\n\n# ⏯️video:\n\n[library.webm](https://github.com/Ghosts6/Library_management_system/assets/95994481/18f40d1b-4e9a-4860-847e-22f7942b19a5)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghosts6%2Flibrary_management_system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghosts6%2Flibrary_management_system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghosts6%2Flibrary_management_system/lists"}