This project is a Django Rest Framework (DRF) application that provides a complete Blog API with JWT authentication, permission management, and detailed API documentation using Swagger.
- Secure user authentication using JWT (JSON Web Tokens).
- Endpoints for login, token refresh, and token verification.
- JWT tokens required for accessing protected routes.
- Create, Read, Update, and Delete blog posts.
- Only the author of a post can edit or delete it.
- Custom permission classes restrict access:
- IsAuthenticatedOrReadOnly: Authenticated users can create/update posts.
- IsOwnerOrReadOnly: Only the post owner can modify or delete a post.
- ViewSets handle CRUD operations for blog posts and user profiles.
- Examples:
BlogPostViewSet
: Manages blog posts.
- DRF's generic views provide customizable endpoints for specific tasks.
- Example:
CreateAPIView
is used for user registration.
- Swagger and ReDoc auto-generate API documentation.
- Accessible via
/swagger/
and/redoc/
.
- Accessible via
git clone https://github.com/your-username/your-repo-name.git
cd your-repo-name
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver
- The API is accessible at
http://127.0.0.1:8000/
. - Swagger UI can be accessed at
http://127.0.0.1:8000/api/schema/swagger/
.
POST /api/v1/auth
POST /api/v1/token/
Authorization: Bearer <your_token>
- Django: High-level web framework.
- Django Rest Framework (DRF): For building the REST API.
- Django Rest Framework Simple JWT: For handling JWT authentication.
- drf-yasg: For auto-generating Swagger and ReDoc API documentation.