This project is a full-stack contacts manager built with Django 5.
It serves both:
- A single-page web UI (HTML/CSS/JS) rendered by Django
- A JSON API for managing contacts
Each contact can have:
- Multiple contact methods (phone, email, social media, address)
- Optional labels for each method (e.g. “Work”, “Home”)
- A primary flag per method type
- A bookmarked flag to mark “frequently accessed” contacts
The app also supports Excel import/export of the address book.
- Contact CRUD
- Create, read, update, delete contacts
- REST-style JSON endpoints under
/contacts/
- Multiple contact methods per contact
- Types:
phone,email,social_media,address - Optional label per method
- Mark methods as Primary
- Types:
- Bookmarks / Frequently accessed
- Toggle bookmark with a star button
- Bookmarked contacts appear in a Frequently Accessed section
- Excel import & export
- Export all contacts and methods to
contacts_export.xlsx - Import contacts from an Excel file in the same format
- Export all contacts and methods to
- Modern frontend
- Single-page UI (
index.html) with:- Dynamic add/edit/delete of contacts
- Add/remove multiple contact methods
- Bookmark toggle
- Import/Export buttons
- Single-page UI (
- CORS-friendly API
- Configured with
django-cors-headers(if you call the API from another origin)
- Configured with
- Language: Python 3.x
- Framework: Django 5.2.7
- Database: SQLite (default Django DB)
- Frontend: Vanilla JS + HTML + CSS (served by Django)
- Excel handling:
pandas+openpyxl - CORS:
django-cors-headers - Port: 8000 by default (
http://127.0.0.1:8000/)
Contacts/
├── Contacts/ # Django project settings
│ ├── __init__.py
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py # Routes: '/', '/contacts/...'
│ └── wsgi.py
│
├── contacts_app/ # Main application
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── models.py # Contact, ContactMethod
│ ├── views.py # API + import/export + bookmark
│ ├── urls.py # /contacts/ endpoints
│ ├── templates/
│ │ └── index.html # Single-page app UI
│ ├── static/
│ │ ├── css/style.css
│ │ └── js/script.js
│ └── migrations/
│ ├── 0001_initial.py
│ ├── 0002_contact_bookmarked.py
│ └── 0003_... + 0004_... # Multiple contact methods
│
├── manage.py
├── requirements.txt
├── README.md
└── LICENSE---
id(int, PK)name(string)bookmarked(bool, defaultFalse)
id(int, PK)contact(FK → Contact, related namecontact_methods)method_type(choice:phone,email,social_media,address)label(optional string, e.g. "Work", "Home")value(text, e.g. phone number, email address, URL, or postal address)is_primary(bool, defaultFalse)
When a method is marked primary, other methods of the same type for that contact are automatically unmarked.
Base path for the API: /contacts/
-
GET
/contacts/
Returns list of all contacts with methods. -
POST
/contacts/
Create a contact with methods.Example body:
{ "name": "Freddy Tao", "bookmarked": true, "contact_methods": [ { "method_type": "phone", "label": "Work", "value": "05925588", "is_primary": false }, { "method_type": "social_media", "label": "Instagram", "value": "freddy_ig", "is_primary": true } ] }
- GET
/contacts/<id>/
Get details for a single contact.
- GET
-
PUT
/contacts/<id>/
Update name, bookmark flag, and replace the contact’s methods with the provided list.{ "name": "Freddy Tao", "bookmarked": false, "contact_methods": [ ... ] }
- DELETE
/contacts/<id>/
Delete a contact.
- DELETE
- POST
/contacts/<id>/bookmark/
Toggle bookmark status for a contact.
- GET
/contacts/<id>/methods/ - POST
/contacts/<id>/methods/ - PUT
/contacts/<id>/methods/<method_id>/ - DELETE
/contacts/<id>/methods/<method_id>/
(Usually the frontend uses the main contact endpoints instead.)
-
GET
/contacts/export/ -
Returns an Excel file
contacts_export.xlsxwith columns:NameBookmarked(Yes/No)PhoneEmailSocial MediaAddress
Each cell for a method type may contain multiple values separated by ;.
Format for each value:
(Label) [Primary]Examples:
[email protected] (Work) [Primary]555-1234 (Home); 555-5678 (Work) [Primary]
- POST
/contacts/import/with form-data:file: Excel file (.xlsxor.xls)
Requirements:
- Must have a
Namecolumn. - Other columns (
Bookmarked,Phone,Email,Social Media,Address) are optional but recommended. - Same text format as the export for labels and
[Primary].
The server responds with:
{ "message": "Successfully imported 3 contact(s)", "imported": 3, "skipped": 1, "errors": [ "Row 5: Name is required" ] }---
git clone Contacts cd Contacts### 2. Create and activate a virtual environment
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate### 3. Install dependencies
pip install -r requirements.txt### 4. Apply migrations
python3 manage.py migrate(If you change models, run python3 manage.py makemigrations first.)
python3 manage.py runserverOpen the app at:
- UI:
http://127.0.0.1:8000/ - API base:
http://127.0.0.1:8000/contacts/
- Use the Add New Contact form to:
- Enter a contact name
- Add one or more contact methods
- Mark methods as Primary as needed
- Use + Add Contact Method to add extra rows.
- Click the star on any contact to bookmark/unbookmark it.
- Use Export to Excel to download the full address book.
- Use Import from Excel to upload a properly formatted Excel file.
This project is licensed under the MIT License.
See the LICENSE file for details.