The Contacts API provides the following endpoints for managing contacts:
-
POST /contacts/
Creates a new contact. Requires contact data in the request body. -
GET /contacts/
Retrieves a list of all contacts. Supports optional query parameters for filtering if implemented.Filtering Options:
first_name
: Filter contacts by their first name. Example:GET /contacts/?first_name=John
last_name
: Filter contacts by their last name. Example:GET /contacts/?last_name=Doe
-
GET /contacts/<id>/
Retrieves details of a specific contact by its unique ID. -
PUT /contacts/<id>/
Updates an existing contact by its unique ID. Requires updated contact data in the request body. -
DELETE /contacts/<id>/
Deletes a specific contact by its unique ID.
Before you begin, ensure you have the following installed:
- Python (>= 3.8)
- pip (Python package manager)
- Git (for cloning the repository)
- Virtual environment tool (optional, but recommended)
Clone the project repository from GitHub:
git clone https://github.com/bo1ko/constacts-drf
cd constacts-drf
Create a virtual environment:
- Linux/macOS:
python3 -m venv .venv
- Windows:
py -m venv .venv
Activate the virtual environment:
- Linux/macOS:
source .venv/bin/activate
- Windows:
.venv\Scripts\activate
Install required packages using pip:
pip install -r requirements.txt
Copy the data from .env.exmaple and then fill in the values
GEO_TOKEN
: You can get it hereGEO_URL
: Leave it as in the exampleGOOGLE_OAUTH2_CLIENT_ID
: The unique Client ID provided by Google.GOOGLE_OAUTH2_CLIENT_SECRET
: The Client Secret associated with the application.GOOGLE_OAUTH2_PROJECT_ID
: The Project ID of your Google Cloud project.
-
Go to the Google Cloud Console.
-
Create or select an existing project.
-
Navigate to APIs & Services > Credentials.
-
Click Create Credentials > OAuth client ID.
-
Set up the consent screen if required, then choose Web application as the application type.
-
After setup, copy the Client ID and Client Secret, and paste them into your
.env
file:GOOGLE_OAUTH2_CLIENT_ID=your-client-id GOOGLE_OAUTH2_CLIENT_SECRET=your-client-secret GOOGLE_OAUTH2_PROJECT_ID=your-project-id
Apply the initial migrations to set up the database structure:
python manage.py makemigrations
python manage.py migrate
Create an admin user for accessing the Django admin panel:
python manage.py createsuperuser
Run the Django development server:
python manage.py runserver