Skip to content

PyWorldGeo/OnlineLibrary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Online Library An interactive Django-based web application that allows users to register, upload, and read digital books, browse by genre or author, and leave comments. It also includes an example test model (Animal) to demonstrate Django’s testing framework.

πŸš€ Features πŸ‘€ User Authentication

Register, login, logout.

Update profile with avatar, bio, and favorite books.

πŸ“– Books Management

Upload books with title, author, description, picture, and file.

Categorize books by multiple genres.

View, read, or delete books.

Add books to personal collection.

πŸ’¬ Comments

Leave comments on books.

Delete comments.

🧠 Search

Search books by name, description, or genre.

πŸ§‘β€πŸ’» Admin Panel

Manage all users, authors, books, genres, comments, and test data (Animal).

🧩 Project Structure bash Copy Edit base/ β”œβ”€β”€ admin.py # Admin configuration β”œβ”€β”€ models.py # Database models β”œβ”€β”€ forms.py # Custom user and book forms β”œβ”€β”€ views.py # Application logic and routes β”œβ”€β”€ urls.py # URL mappings β”œβ”€β”€ tests.py # Unit tests β”œβ”€β”€ middleware.py # Custom middleware example β”œβ”€β”€ templates/base/ # HTML templates └── static/ # Static files (CSS, JS, images) βš™οΈ Models Overview User: Extends Django’s AbstractUser with bio, avatar, and favorite books.

Book: Includes name, description, genre, author, file, and creator.

Author and Genre: Linked to books.

Comment: Linked to both User and Book.

Animal: Example test model (used in tests.py).

🧠 Middleware Example NewMiddleware demonstrates how to execute logic before and after each request:

python Copy Edit class NewMiddleware: def call(self, request): print("Before") response = self.get_response(request) print("After") return response πŸ§ͺ Testing Example tests.py includes a basic Django unit test:

python Copy Edit class AnimalTestCase(TestCase): def test_animal_can_speak(self): lion = Animal.objects.get(name='Lion') self.assertEquals(lion.speak(), 'The Lion says "Roar"') Run tests with:

bash Copy Edit python manage.py test

πŸ–ΌοΈ Example URLs Page URL Home / About /about/ Contact /contact/ Login /login/ Register /register/ Profile /profile/<user_id>/ Add Book /add/

🧰 Admin Management Access the admin interface at /admin/ to manage:

Users

Books

Authors

Genres

Comments

Animals

🧾 License This project is open-source and available under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •