or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

accounts.mdauthentication.mdcases.mdcontacts.mddocuments.mdevents.mdindex.mdinvoices.mdleads.mdopportunities.mdtasks.mdteams.md
tile.json

tessl/pypi-django-crm

Open Source CRM developed on Django framework with REST API for contact, lead, account, and opportunity management

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/django-crm@0.10.x

To install, run

npx @tessl/cli install tessl/pypi-django-crm@0.10.0

index.mddocs/

Django CRM

Django CRM is an open-source Customer Relationship Management system built on the Django web framework with Django REST Framework. It provides a comprehensive CRM solution with contact management, lead tracking, account management, opportunity management, task management, event management, case management, and team collaboration, all accessible through a REST API with JWT authentication.

Package Information

  • Package Name: django-crm
  • Package Type: Python Django Application
  • Language: Python (Django/DRF)
  • Version: 0.10.0
  • Installation: Clone and deploy Django application or integrate as Django package
  • Authentication: JWT (JSON Web Tokens)
  • API Base URL: /api/

Core Setup

Django Integration

# settings.py
INSTALLED_APPS = [
    'rest_framework',
    'rest_framework_simplejwt',
    'corsheaders',
    'drf_spectacular',
    'common',
    'accounts',
    'cases',
    'contacts',
    'emails',
    'leads',
    'opportunity',
    'planner',
    'tasks',
    'invoices',
    'events',
    'teams',
]

# API Configuration
REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework_simplejwt.authentication.JWTAuthentication',
    ),
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
    'PAGE_SIZE': 10,
}

URL Configuration

# urls.py
from django.urls import path, include

urlpatterns = [
    path('api/', include('common.app_urls', namespace='common_urls')),
    path('schema/', SpectacularAPIView.as_view(), name='schema'),
    path('swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
]

Basic Usage

Authentication

import requests

# Login (if implementing custom auth)
response = requests.post('http://your-crm.com/api/auth/google/', {
    'token': 'google_oauth_token'
})
token_data = response.json()
access_token = token_data['access']

# Set up headers for authenticated requests
headers = {
    'Authorization': f'Bearer {access_token}',
    'organization-id': 'your_org_uuid',  # Required for org-scoped operations
    'Content-Type': 'application/json'
}

Basic API Operations

import requests

# Get dashboard data
dashboard = requests.get('http://your-crm.com/api/dashboard/', headers=headers)
print(dashboard.json())

# Create a contact
contact_data = {
    'first_name': 'John',
    'last_name': 'Doe',
    'primary_email': 'john.doe@example.com',
    'mobile_number': '+1234567890',
    'assigned_to': ['user_uuid']
}
response = requests.post('http://your-crm.com/api/contacts/',
                        json=contact_data, headers=headers)
contact = response.json()

# Create a lead
lead_data = {
    'first_name': 'Jane',
    'last_name': 'Smith',
    'email': 'jane.smith@company.com',
    'phone': '+1987654321',
    'status': 'assigned',
    'source': 'Website',
    'account_name': 'ACME Corp',
    'contacts': [contact['id']],
    'assigned_to': ['user_uuid']
}
response = requests.post('http://your-crm.com/api/leads/',
                        json=lead_data, headers=headers)
lead = response.json()

Architecture

Django CRM follows a modular Django application architecture with these key components:

  • Organization-based Multi-tenancy: All data is scoped by organization with role-based access control
  • Django REST Framework API: Complete REST API for all CRM operations
  • JWT Authentication: Token-based authentication with refresh token support
  • Celery Background Tasks: Asynchronous processing for emails and bulk operations
  • File Attachment Support: Upload and manage files attached to CRM entities
  • Comprehensive Activity Tracking: Comments and audit trails for all entities

The system is designed around these main entity types:

  • Accounts: Customer companies/organizations
  • Contacts: Individual people within accounts
  • Leads: Potential customers being qualified
  • Opportunities: Sales deals being pursued
  • Tasks: Work items and to-dos
  • Events: Calendar events and meetings
  • Cases: Support cases and issues
  • Teams: User groups for collaboration

Capabilities

Authentication & User Management

Core authentication, user management, organization management, and administrative functions including JWT token handling, Google OAuth integration, user roles, and organization-scoped operations.

# Authentication endpoints
POST /api/auth/google/  # Google OAuth login
POST /api/auth/refresh-token/  # Refresh JWT token

# User management
GET /api/profile/  # Get current user profile
GET /api/users/  # List organization users
POST /api/users/  # Create new user
GET /api/user/<str:pk>/  # Get user details
PUT /api/user/<str:pk>/  # Update user
DELETE /api/user/<str:pk>/  # Delete user
POST /api/user/<str:pk>/status/  # Update user status
GET /api/users/get-teams-and-users/  # Get teams and users list

# Organization management
GET /api/org/  # Get user organizations
POST /api/org/  # Create organization

# API settings and domains
GET /api/api-settings/  # List API domain settings
POST /api/api-settings/  # Create API domain setting
GET /api/api-settings/<str:pk>/  # Get domain setting details
PUT /api/api-settings/<str:pk>/  # Update domain setting
DELETE /api/api-settings/<str:pk>/  # Delete domain setting

Authentication & Users

Account Management

Customer account management including company information, billing details, contact associations, team assignments, and account-related activities. Supports both open and closed account states with comprehensive search and filtering.

GET /api/accounts/  # List accounts with filtering
POST /api/accounts/  # Create new account
GET /api/accounts/<str:pk>/  # Get account details
PUT /api/accounts/<str:pk>/  # Update account
DELETE /api/accounts/<str:pk>/  # Delete account
POST /api/accounts/<str:pk>/create_mail/  # Send email from account
POST /api/accounts/comment/<str:pk>/  # Add comment to account
POST /api/accounts/attachment/<str:pk>/  # Add attachment to account

Account Management

Contact Management

Individual contact management with personal information, organizational relationships, address details, and contact history. Contacts can be associated with accounts and assigned to team members.

GET /api/contacts/  # List contacts with search/filtering
POST /api/contacts/  # Create new contact
GET /api/contacts/<str:pk>/  # Get contact details
PUT /api/contacts/<str:pk>/  # Update contact
DELETE /api/contacts/<str:pk>/  # Delete contact
POST /api/contacts/comment/<str:pk>/  # Add comment to contact
POST /api/contacts/attachment/<str:pk>/  # Add attachment to contact

Contact Management

Lead Management

Lead tracking and qualification system with lead sources, status management, conversion to accounts, bulk import capabilities, and external API integration for lead capture.

POST /api/leads/create-from-site/  # External lead creation (API key auth)
GET /api/leads/  # List leads (excludes converted)
POST /api/leads/  # Create lead (with auto-conversion option)
POST /api/leads/upload/  # Bulk lead import
GET /api/leads/<str:pk>/  # Get lead details
PUT /api/leads/<str:pk>/  # Update lead
DELETE /api/leads/<str:pk>/  # Delete lead
POST /api/leads/comment/<str:pk>/  # Add comment to lead
POST /api/leads/attachment/<str:pk>/  # Add attachment to lead
GET /api/leads/companies/  # List lead companies
GET /api/leads/company/<str:pk>/  # Get company details

Lead Management

Opportunity Management

Sales opportunity tracking with deal stages, probability management, revenue forecasting, contact associations, and pipeline management from lead qualification through close.

GET /api/opportunities/  # List opportunities with filtering
POST /api/opportunities/  # Create new opportunity
GET /api/opportunities/<str:pk>/  # Get opportunity details
PUT /api/opportunities/<str:pk>/  # Update opportunity
DELETE /api/opportunities/<str:pk>/  # Delete opportunity
POST /api/opportunities/comment/<str:pk>/  # Add comment to opportunity
POST /api/opportunities/attachment/<str:pk>/  # Add attachment to opportunity

Opportunity Management

Task Management

Task and to-do management with priority levels, due dates, assignments, status tracking, and integration with accounts, contacts, and other CRM entities.

GET /api/tasks/  # List tasks
POST /api/tasks/  # Create new task
GET /api/tasks/<str:pk>/  # Get task details
PUT /api/tasks/<str:pk>/  # Update task
DELETE /api/tasks/<str:pk>/  # Delete task
POST /api/tasks/comment/<str:pk>/  # Add comment to task
POST /api/tasks/attachment/<str:pk>/  # Add attachment to task

Task Management

Event Management

Calendar event management with scheduling, contact invitations, event types (calls, meetings, tasks), and integration with CRM entities for comprehensive activity tracking.

GET /api/events/  # List events
POST /api/events/  # Create new event
GET /api/events/<str:pk>/  # Get event details
PUT /api/events/<str:pk>/  # Update event
DELETE /api/events/<str:pk>/  # Delete event
POST /api/events/comment/<str:pk>/  # Add comment to event
POST /api/events/attachment/<str:pk>/  # Add attachment to event

Event Management

Case Management

Support case tracking with priority levels, case types, status management, resolution tracking, and integration with accounts and contacts for comprehensive customer support.

GET /api/cases/  # List cases
POST /api/cases/  # Create new case
GET /api/cases/<str:pk>/  # Get case details
PUT /api/cases/<str:pk>/  # Update case
DELETE /api/cases/<str:pk>/  # Delete case
POST /api/cases/comment/<str:pk>/  # Add comment to case
POST /api/cases/attachment/<str:pk>/  # Add attachment to case

Case Management

Invoice Management

Invoice creation, management, and billing operations including invoice generation, status tracking, payment management, and PDF generation. Complete invoice lifecycle from creation through payment with email notifications.

Note: Invoice API endpoints are implemented but not currently routed in the main application URLs. Add to URL routing to enable.

GET /api/invoices/  # List invoices with filtering
POST /api/invoices/  # Create new invoice
GET /api/invoices/<str:pk>/  # Get invoice details
PUT /api/invoices/<str:pk>/  # Update invoice
DELETE /api/invoices/<str:pk>/  # Delete invoice
POST /api/invoices/<str:pk>/send-mail/  # Send invoice by email
POST /api/invoices/<str:pk>/download/  # Download invoice PDF
POST /api/invoices/<str:pk>/status/  # Update invoice status
POST /api/invoices/comment/<str:pk>/  # Add comment to invoice
POST /api/invoices/attachment/<str:pk>/  # Add attachment to invoice

Invoice Management

Team Management

Team creation and management for organizing users into collaborative groups, enabling team-based assignments and permissions across all CRM entities.

GET /api/teams/  # List organization teams
POST /api/teams/  # Create new team
GET /api/teams/<str:pk>/  # Get team details
PUT /api/teams/<str:pk>/  # Update team
DELETE /api/teams/<str:pk>/  # Delete team

Team Management

Document Management

File upload, storage, and sharing system with document organization, team-based sharing permissions, and attachment capabilities across all CRM entities.

GET /api/documents/  # List documents (active/inactive)
POST /api/documents/  # Upload new document
GET /api/documents/<str:pk>/  # Get document details
PUT /api/documents/<str:pk>/  # Update document
DELETE /api/documents/<str:pk>/  # Delete document

Document Management

Common Data Types

class User:
    """Django CRM User model with organization-based multi-tenancy"""
    id: str  # UUID
    email: str
    first_name: str
    last_name: str
    role: str  # 'ADMIN' or 'USER'
    phone: str
    is_active: bool
    org: str  # Organization UUID
    address: dict  # Address fields

class Organization:
    """Organization/Company for multi-tenant scoping"""
    id: str  # UUID
    name: str
    slug: str
    billing_address: dict
    billing_city: str
    billing_state: str

class Address:
    """Common address structure used across entities"""
    address_line: str
    street: str
    city: str
    state: str
    postcode: str
    country: str

class Comment:
    """Comments available on all major entities"""
    id: str  # UUID
    comment: str
    commented_on: datetime
    commented_by: User

class Attachment:
    """File attachments for entities"""
    id: str  # UUID
    attachment: str  # File path/URL
    created_on: datetime
    created_by: User

Error Responses

class ErrorResponse:
    """Standard error response format"""
    detail: str  # Error message
    field_errors: dict  # Field-specific validation errors

class ValidationErrorResponse:
    """Validation error response"""
    field_name: list[str]  # List of error messages for the field

Pagination

class PaginatedResponse:
    """Standard pagination format for list endpoints"""
    count: int  # Total number of items
    next: str | None  # URL for next page
    previous: str | None  # URL for previous page
    results: list  # Array of items for current page

All list endpoints return paginated results using Django REST Framework's LimitOffsetPagination with a default page size of 10 items. Use ?limit=N&offset=M parameters to control pagination.