Open Source CRM developed on Django framework with REST API for contact, lead, account, and opportunity management
Individual contact management for people within customer organizations. Contacts represent individual persons who can be associated with accounts, included in opportunities, assigned tasks, and participate in various CRM activities.
List and search contacts with comprehensive filtering options.
def list_contacts(name: str = None, city: str = None, phone: str = None,
email: str = None, assigned_to: str = None,
limit: int = 10, offset: int = 0) -> dict:
"""
List contacts with filtering and search.
Args:
name (str, optional): Filter by first or last name (partial match)
city (str, optional): Filter by city
phone (str, optional): Filter by phone number
email (str, optional): Filter by email address
assigned_to (str, optional): Filter by assigned user UUID
limit (int): Number of results per page (default: 10)
offset (int): Number of results to skip (default: 0)
Returns:
dict: Paginated contacts with metadata
Headers Required:
Authorization: Bearer <access_token>
organization-id: <org_uuid>
Example:
GET /api/contacts/?name=john&city=new%20york&limit=5
Response:
{
"count": 25,
"next": "/api/contacts/?limit=5&offset=5",
"previous": null,
"results": [
{
"id": "contact-uuid",
"first_name": "John",
"last_name": "Doe",
"primary_email": "john.doe@acme.com",
"mobile_number": "+1234567890",
"organization": "ACME Corporation",
"department": "Sales",
"address_line": "123 Main St",
"city": "New York",
"state": "NY",
"postcode": "10001",
"country": "USA",
"created_on": "2023-01-15T10:30:00Z",
"assigned_to": ["user1-uuid"],
"teams": ["team1-uuid"]
}
]
}
"""Create new contacts with personal and organizational information.
def create_contact(contact_data: dict) -> dict:
"""
Create a new contact.
Args:
contact_data (dict): Contact information and associations
Returns:
dict: Created contact details
Headers Required:
Authorization: Bearer <access_token>
organization-id: <org_uuid>
Content-Type: multipart/form-data (if including attachments)
Example:
POST /api/contacts/
{
"first_name": "Jane",
"last_name": "Smith",
"primary_email": "jane.smith@client.com",
"mobile_number": "+1987654321",
"secondary_email": "j.smith@client.com",
"organization": "Client Corp",
"department": "Marketing",
"designation": "Marketing Manager",
"address_line": "456 Business Ave",
"street": "Suite 200",
"city": "Boston",
"state": "MA",
"postcode": "02101",
"country": "USA",
"assigned_to": ["user1-uuid"],
"teams": ["team1-uuid"]
}
Response:
{
"id": "new-contact-uuid",
"first_name": "Jane",
"last_name": "Smith",
...contact details...
}
"""Get comprehensive contact information and perform updates.
def get_contact(pk: str) -> dict:
"""
Get detailed contact information.
Args:
pk (str): Contact UUID
Returns:
dict: Complete contact details with related entities
Headers Required:
Authorization: Bearer <access_token>
organization-id: <org_uuid>
Example:
GET /api/contacts/contact-uuid/
Response:
{
"contact_obj": {
"id": "contact-uuid",
"first_name": "John",
"last_name": "Doe",
"primary_email": "john.doe@acme.com",
"secondary_email": "j.doe@acme.com",
"mobile_number": "+1234567890",
"organization": "ACME Corporation",
"department": "Sales",
"designation": "Sales Director",
"address_line": "123 Main St",
"street": "Floor 5",
"city": "New York",
"state": "NY",
"postcode": "10001",
"country": "USA",
"created_on": "2023-01-15T10:30:00Z",
"created_by": "user-uuid"
},
"address_obj": {...address details...},
"assigned_to": [...assigned users...],
"teams": [...assigned teams...],
"comments": [...contact comments...],
"attachments": [...contact attachments...],
"tasks": [...related tasks...],
"users_mention": [...users for @mentions...]
}
"""
def update_contact(pk: str, contact_data: dict) -> dict:
"""
Update contact information.
Args:
pk (str): Contact UUID
contact_data (dict): Updated contact information
Returns:
dict: Updated contact details
Headers Required:
Authorization: Bearer <access_token>
organization-id: <org_uuid>
Example:
PUT /api/contacts/contact-uuid/
{
"first_name": "John",
"last_name": "Doe",
"mobile_number": "+1234567891",
"department": "Senior Sales"
}
"""
def delete_contact(pk: str) -> None:
"""
Delete a contact.
Args:
pk (str): Contact UUID
Returns:
None: 204 No Content on success
Headers Required:
Authorization: Bearer <access_token>
organization-id: <org_uuid>
Example:
DELETE /api/contacts/contact-uuid/
"""Manage comments and file attachments for contacts.
def add_contact_comment_or_attachment(pk: str, comment: str = None,
attachment: file = None) -> dict:
"""
Add comment or attachment to contact.
Args:
pk (str): Contact UUID
comment (str, optional): Comment text
attachment (file, optional): File to attach
Returns:
dict: Success response
Headers Required:
Authorization: Bearer <access_token>
organization-id: <org_uuid>
Content-Type: multipart/form-data (for attachments)
Example:
POST /api/contacts/contact-uuid/
{
"comment": "Had great conversation about upcoming project"
}
"""
def edit_contact_comment(pk: str, comment: str) -> dict:
"""
Edit a contact comment.
Args:
pk (str): Comment UUID
comment (str): Updated comment text
Returns:
dict: Updated comment
Headers Required:
Authorization: Bearer <access_token>
Example:
PUT /api/contacts/comment/comment-uuid/
{
"comment": "Updated comment text"
}
"""
def delete_contact_comment(pk: str) -> None:
"""
Delete a contact comment.
Args:
pk (str): Comment UUID
Returns:
None: 204 No Content on success
Headers Required:
Authorization: Bearer <access_token>
Example:
DELETE /api/contacts/comment/comment-uuid/
"""
def delete_contact_attachment(pk: str) -> None:
"""
Delete a contact attachment.
Args:
pk (str): Attachment UUID
Returns:
None: 204 No Content on success
Headers Required:
Authorization: Bearer <access_token>
Example:
DELETE /api/contacts/attachment/attachment-uuid/
"""class Contact:
"""Contact model representing an individual person"""
id: str # UUID
first_name: str # Required
last_name: str # Required
primary_email: str # Primary email address
secondary_email: str # Alternative email
mobile_number: str # Primary phone
organization: str # Company/organization name
department: str # Department within organization
designation: str # Job title/position
# Address information
address_line: str
street: str # Additional address line
city: str
state: str
postcode: str
country: str
# Metadata
created_on: datetime
created_by: str # User UUID
org: str # Organization UUID
# Associations
assigned_to: list[str] # User UUIDs
teams: list[str] # Team UUIDs
class ContactComment:
"""Comments on contacts"""
id: str # UUID
comment: str
contact: str # Contact UUID
commented_on: datetime
commented_by: str # User UUID
class ContactAttachment:
"""File attachments on contacts"""
id: str # UUID
attachment: str # File path/URL
contact: str # Contact UUID
created_on: datetime
created_by: str # User UUIDContacts support multiple search and filter options:
name parameter searches both first and last names (partial matching)city filtering for geographic organizationphone and email filteringassigned_to filtering by user UUIDAll text-based filters support partial matching and are case-insensitive.
Contacts can be associated with and participate in:
This makes contacts central to relationship management and communication tracking across the CRM system.
Install with Tessl CLI
npx tessl i tessl/pypi-django-crm