Skip to content

bo1ko/constacts-drf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contacts Management API

API Endpoints

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.

Prerequisites

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)

Installation Guide

Step 1: Clone the Repository

Clone the project repository from GitHub:

git clone https://github.com/bo1ko/constacts-drf
cd constacts-drf

Step 2: Create and Activate a Virtual Environment

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

Step 3. Install Project Dependencies

Install required packages using pip:

pip install -r requirements.txt

Step 4. Create and fill .env

Copy the data from .env.exmaple and then fill in the values

  • GEO_TOKEN: You can get it here
  • GEO_URL: Leave it as in the example
  • GOOGLE_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.

Steps to Obtain Google OAuth2 Credentials

  1. Go to the Google Cloud Console.

  2. Create or select an existing project.

  3. Navigate to APIs & Services > Credentials.

  4. Click Create Credentials > OAuth client ID.

  5. Set up the consent screen if required, then choose Web application as the application type.

  6. 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
    

Step 5: Set Up the Database

Apply the initial migrations to set up the database structure:

python manage.py makemigrations
python manage.py migrate

Step 6: Create a Superuser (Optional)

Create an admin user for accessing the Django admin panel:

python manage.py createsuperuser

Step 7: Start the Development Server

Run the Django development server:

python manage.py runserver

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages