https://github.com/mohamed-taha-essa/django-blog
simple Django blog using function and class based view
https://github.com/mohamed-taha-essa/django-blog
bootstrap5 cbv class django git github oop python
Last synced: 3 months ago
JSON representation
simple Django blog using function and class based view
- Host: GitHub
- URL: https://github.com/mohamed-taha-essa/django-blog
- Owner: Mohamed-Taha-Essa
- Created: 2023-11-17T08:04:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-09T06:52:08.000Z (6 months ago)
- Last Synced: 2025-01-21T21:22:22.836Z (5 months ago)
- Topics: bootstrap5, cbv, class, django, git, github, oop, python
- Language: Python
- Homepage:
- Size: 43 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple Django Blog Application
This is a basic Django blog project that demonstrates the use of both **function-based views (FBVs)** and **class-based views (CBVs)** for managing blog posts. It includes functionality to list, create, update, delete, and view blog posts.
---
## Features
1. **Post Listing**: Displays a list of all blog posts.
2. **Post Details**: Shows the details of a specific post.
3. **Create Post**: Allows creating a new blog post.
4. **Update Post**: Allows editing an existing blog post.
5. **Delete Post**: Enables deleting a blog post.---
## Requirements
- **Python**: >= 3.8
- **Django**: >= 4.x
- **SQLite** (default database for Django, or another configured database)---
## Installation and Setup
1. Clone the repository:
```bash
git clone
cd
```2. Create and activate a virtual environment:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```3. Install dependencies:
```bash
pip install -r requirements.txt
```4. Apply migrations:
```bash
python manage.py migrate
```5. Start the development server:
```bash
python manage.py runserver
```6. Access the application at `http://127.0.0.1:8000/`.
---
## URL Patterns
### Function-Based Views (FBVs)
| URL Pattern | Description |
|------------------------------|------------------------------|
| `/post_list/` | List all posts |
| `/post_list/` | Post details |
| `/creat_post/` | Create a new post |
| `/update_post/` | Update a specific post |
| `/delet_post/` | Delete a specific post |### Class-Based Views (CBVs)
| URL Pattern | View | Description |
|------------------------------|---------------------------|------------------------------|
| `/` | `PostList` | List all posts |
| `/post//` | `PostDetail` | Post details |
| `/post/new/` | `PostCreate` | Create a new post |
| `/post//edit/` | `PostUpdate` | Update a specific post |
| `/post//delete/` | `PostDelete` | Delete a specific post |---
## Directory Structure
```
myblog/
│
├── posts/
│ ├── views.py # Contains FBVs and CBVs
│ ├── models.py # Post model definition
│ ├── urls.py # URL configurations
│ ├── templates/ # HTML templates for the app
│ └── forms.py # Optional: Django forms for posts
│
├── manage.py # Django management script
├── settings.py # Django project settings
└── urls.py # Project-level URL configurations
```---
## Static and Media Files
- **Static Files**: Served from `STATIC_URL` during development.
- **Media Files**: Uploaded files are served from `MEDIA_URL` during development.---
## Contribution
Feel free to fork this repository and submit pull requests for any improvements or bug fixes.
---
## Acknowledgments
- Built using Django's function-based and class-based views.
- Simplified for educational purposes.