DevBlog API is a Django-based RESTful API for managing blog posts, user authentication, and more.
Follow these steps to set up the project locally:
-
Clone the Repository
git clone https://github.com/Mouhamed-B/devblog-api.git cd devblog-api -
Create a Virtual Environment It is recommended to use a virtual environment to manage dependencies.
python -m venv .venv
-
Activate the Virtual Environment
- On Windows:
.venv\Scripts\activate
- On macOS/Linux:
source .venv/bin/activate
- On Windows:
-
Install Dependencies Install the required packages using pip:
pip install -r requirements.txt
-
Set Up Environment Variables Create a
.envfile in the root directory and add the necessary environment variables. You can use.env.exampleas a reference. -
Run Migrations Apply the database migrations:
python manage.py migrate
-
Create a Superuser (Optional) If you want to access the Django admin panel, create a superuser:
python manage.py createsuperuser
To start the development server, run:
python manage.py runserverThe application will be available at http://127.0.0.1:8000/.
Swagger UI for the API documentation available at http://127.0.0.1:8000/api/schema/swagger-ui/
- User Registration:
POST /api/register/ - User Login:
POST /api/login/ - Create Post:
POST /api/posts/ - Update Post:
PUT /api/posts/{id}/ - Retrieve Post:
GET /api/posts/{id}/
Refer to the API documentation for more details on request and response formats.
To run the tests, use the following command:
python manage.py testhttps://devblog-api.vercel.app/
https://devblog-api.vercel.app/api/schema/swagger-ui/
We allow "*.vercel.app" subdomains in ALLOWED_HOSTS, in addition to 127.0.0.1:
# api/settings.py
ALLOWED_HOSTS = ['127.0.0.1', '.vercel.app']The wsgi module must use a public variable named app to expose the WSGI application:
# api/wsgi.py
app = get_wsgi_application()The corresponding WSGI_APPLICATION setting is configured to use the app variable from the api.wsgi module:
# api/settings.py
WSGI_APPLICATION = 'api.wsgi.app'