Django-Blog-App is a comprehensive blogging platform built with Django. It includes features such as user authentication, blog post creation, commenting, and more. The project is designed to be easily extendable and customizable.
- User authentication and authorization
- Blog post creation, editing, and deletion
- Commenting on blog posts
- Categorization of blog posts
- JWT authentication for API endpoints
- Background task processing with Celery
- Django
- Django REST Framework
- Celery
- Redis
- Docker
- Pytest
The project structure is as follows:
Django-Blog-App/
├── core/
│ ├── accounts/
│ ├── blog/
│ ├── comment/
│ ├── core/
│ ├── static/
│ ├── templates/
│ ├── manage.py
│ └── requirements.txt
├── docker-compose.yml
├── Dockerfile
└── README.md
The available API endpoints are as follows:
POST /accounts/api/v1/register/- Register a new userPOST /accounts/api/v1/token/login/- Login with email and passwordPOST /accounts/api/v1/token/logout/- LogoutPOST /accounts/api/v1/jwt/create/- Create JWT tokenPOST /accounts/api/v1/jwt/refresh/- Refresh JWT tokenPOST /accounts/api/v1/jwt/verify/- Verify JWT tokenPOST /accounts/api/v1/change-password/- Change passwordPOST /accounts/api/v1/test-email/- Send test emailGET /accounts/api/v1/verify-email/<str:token>/- Verify emailPOST /accounts/api/v1/resend-verification-email/- Resend verification email
GET /blog/api/v1/posts/- List all postsPOST /blog/api/v1/posts/- Create a new postGET /blog/api/v1/posts/<int:pk>/- Retrieve a postPUT /blog/api/v1/posts/<int:pk>/- Update a postDELETE /blog/api/v1/posts/<int:pk>/- Delete a postGET /blog/api/v1/categories/- List all categoriesPOST /blog/api/v1/categories/- Create a new categoryGET /blog/api/v1/categories/<int:pk>/- Retrieve a categoryPUT /blog/api/v1/categories/<int:pk>/- Update a categoryDELETE /blog/api/v1/categories/<int:pk>/- Delete a category
GET /comments/api/v1/comments/- List all commentsPOST /comments/api/v1/comments/- Create a new commentGET /comments/api/v1/comments/<int:pk>/- Retrieve a commentPUT /comments/api/v1/comments/<int:pk>/- Update a commentDELETE /comments/api/v1/comments/<int:pk>/- Delete a comment
To set up the project, follow these steps:
-
Clone the repository:
git clone https://github.com/MahdiSiamaki/Django-Advance-Blog.git cd Django-Advance-Blog -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Set up the database:
python manage.py migrate
-
Create a superuser:
python manage.py createsuperuser
-
Run the development server:
python manage.py runserver
To run the project using Docker, follow these steps:
-
Build and start the Docker containers:
docker-compose up --build
-
Access the application at
http://127.0.0.1:8000/. -
Access the admin panel at
http://127.0.0.1:8000/admin/and log in with the superuser credentials.
The project uses Celery for background processing. To start the Celery worker, follow these steps:
-
Start the Celery worker:
docker-compose run worker
-
The Celery worker will now process background tasks.
The project is configured to use SMTP for sending emails. The email settings are defined in core/core/settings.py and docker-compose.yml. By default, the project uses smtp4dev for local email testing.
To run tests using pytest, follow these steps:
- Run the tests:
pytest
To use the project, follow these guidelines:
- Access the admin panel at
http://127.0.0.1:8000/admin/and log in with the superuser credentials. - Create blog posts, categories, and tags from the admin panel.
- Visit the homepage at
http://127.0.0.1:8000/to see the blog posts. - Users can register, log in, and comment on blog posts.
-
Issue: Unable to connect to the database. Solution: Ensure that the database service is running and the connection settings in
core/core/settings.pyare correct. -
Issue: Email not being sent. Solution: Check the email settings in
core/core/settings.pyand ensure that the SMTP server is running. -
Issue: Celery worker not processing tasks. Solution: Ensure that the Celery worker is running and connected to the Redis server.
To contribute to the project, follow these steps:
- Fork the repository.
- Create a new branch:
git checkout -b feature-branch
- Make your changes and commit them:
git commit -m "Description of the feature" - Push to the branch:
git push origin feature-branch
- Create a pull request.
For support or inquiries, please contact the project maintainer at siamaki.me@gmail.com.
This project is licensed under the MIT License. See the LICENSE file for more information.