docs
0
# Console Interface
1
2
Command-line interface for Creme CRM administration, including server management, database operations, user management, and system maintenance tasks.
3
4
## Capabilities
5
6
### Main Entry Point
7
8
Primary command-line interface for all administrative tasks.
9
10
```python { .api }
11
def execute():
12
"""
13
Main Django management command executor for Creme CRM.
14
Sets up Django environment and executes management commands.
15
16
Environment Variables:
17
- DJANGO_SETTINGS_MODULE: Django settings module (defaults to 'creme.settings')
18
- COVERAGE_PROCESS_START: Enable coverage tracking for parallel test runs
19
20
Usage Examples:
21
creme runserver 8000
22
creme migrate
23
creme collectstatic
24
creme creme_populate
25
26
The function handles:
27
- Setting up Python path
28
- Configuring Django settings
29
- Coverage tracking setup for tests
30
- Command line argument processing
31
"""
32
```
33
34
### Core Management Commands
35
36
Essential database and system management commands.
37
38
```python { .api }
39
# Database initialization and population
40
def creme_populate(**options):
41
"""
42
Initialize database with default data, users, and configuration.
43
44
Parameters:
45
- verbosity: int, output verbosity level (0-3)
46
- interactive: bool, prompt for user input
47
- skip_checks: bool, skip system checks
48
49
Creates:
50
- Default user roles and permissions
51
- Core relation types and property types
52
- Default currencies and VAT rates
53
- System configuration entries
54
- Sample data (optional)
55
"""
56
57
def creme_createstaffuser(**options):
58
"""
59
Create administrative staff user accounts.
60
61
Parameters:
62
- username: str, username for new staff user
63
- email: str, email address for user
64
- password: str, password (prompts if not provided)
65
- role: str, role name to assign to user
66
67
Features:
68
- Interactive prompts for missing information
69
- Password validation
70
- Automatic staff and superuser flag setting
71
- Role assignment integration
72
"""
73
74
def creme_start_project(**options):
75
"""
76
Initialize new Creme CRM project structure.
77
78
Parameters:
79
- project_name: str, name of new project
80
- template: str, project template to use
81
- destination: str, target directory
82
83
Creates:
84
- Project directory structure
85
- Settings files
86
- URL configuration
87
- Initial migrations
88
- Static files setup
89
"""
90
91
def creme_uninstall(**options):
92
"""
93
Remove application modules and associated data.
94
95
Parameters:
96
- app_labels: list, application names to remove
97
- force: bool, skip confirmation prompts
98
- keep_data: bool, preserve database tables
99
100
Operations:
101
- Remove app from INSTALLED_APPS
102
- Delete migrations (optional)
103
- Remove database tables (optional)
104
- Clean up static files
105
"""
106
107
def creme_job_manager(**options):
108
"""
109
Background job management and monitoring.
110
111
Parameters:
112
- action: str, management action (start, stop, status, clear)
113
- job_id: str, specific job to manage
114
- queue: str, job queue to operate on
115
116
Actions:
117
- start: Start job processing
118
- stop: Stop job processing
119
- status: Show job queue status
120
- clear: Remove completed/failed jobs
121
- restart: Restart job processing
122
"""
123
```
124
125
### Development and Maintenance Commands
126
127
Commands for development, testing, and system maintenance.
128
129
```python { .api }
130
def build_secret_key(**options):
131
"""
132
Generate Django SECRET_KEY for production deployment.
133
134
Parameters:
135
- length: int, key length (default: 50)
136
- output: str, output file path
137
138
Returns:
139
str: Generated secret key using cryptographically secure random generator
140
141
Usage:
142
creme build_secret_key --output=.env
143
creme build_secret_key --length=100
144
"""
145
146
def entity_factory(**options):
147
"""
148
Create test entities for development and testing.
149
150
Parameters:
151
- entity_type: str, type of entities to create
152
- count: int, number of entities to generate
153
- user: str, username to assign as owner
154
- random_data: bool, use random data generation
155
156
Supports:
157
- Contact and Organization generation
158
- Activity and event creation
159
- Document and folder structures
160
- Product and service catalogs
161
- Realistic fake data generation
162
"""
163
```
164
165
### Internationalization Commands
166
167
Commands for translation and localization management.
168
169
```python { .api }
170
def i18n_duplicates(**options):
171
"""
172
Find duplicate translation strings across language files.
173
174
Parameters:
175
- locale: str, specific locale to check
176
- output_format: str, output format (text, json, csv)
177
178
Reports:
179
- Identical translations in different contexts
180
- Potential consolidation opportunities
181
- Translation consistency issues
182
"""
183
184
def i18n_empty(**options):
185
"""
186
Find empty or missing translations in language files.
187
188
Parameters:
189
- locale: str, specific locale to check
190
- fix: bool, automatically remove empty entries
191
192
Identifies:
193
- Empty translation strings
194
- Missing translations
195
- Untranslated strings
196
"""
197
198
def i18n_overload(**options):
199
"""
200
Manage translation overrides for customization.
201
202
Parameters:
203
- locale: str, target locale
204
- key: str, translation key to override
205
- value: str, new translation value
206
207
Features:
208
- Custom translation management
209
- Override system translations
210
- Maintain upgrade compatibility
211
"""
212
213
def i18n_plural_forms(**options):
214
"""
215
Validate plural form expressions in translation files.
216
217
Parameters:
218
- locale: str, specific locale to validate
219
220
Checks:
221
- Plural form syntax correctness
222
- Language-specific plural rules
223
- Consistency across translation files
224
"""
225
226
def i18n_spellcheck(**options):
227
"""
228
Spell check translation strings using dictionaries.
229
230
Parameters:
231
- locale: str, target locale for checking
232
- dictionary: str, custom dictionary file
233
- ignore_words: list, words to ignore
234
235
Features:
236
- Multiple language support
237
- Custom dictionary integration
238
- Exclude technical terms
239
- Generate correction suggestions
240
"""
241
```
242
243
### Application-Specific Commands
244
245
Commands for specific application modules and features.
246
247
```python { .api }
248
def activities_create_default_calendars(**options):
249
"""
250
Create default calendar structure for activities module.
251
252
Parameters:
253
- user: str, username to assign calendars to
254
- team_calendars: bool, create team calendars
255
256
Creates:
257
- Personal calendars for users
258
- Team/shared calendars
259
- Default calendar colors and settings
260
- Calendar permission structure
261
"""
262
263
def crudity_action_factory(**options):
264
"""
265
Create CRUD actions for external data import system.
266
267
Parameters:
268
- entity_type: str, target entity type
269
- source: str, data source configuration
270
- mapping: str, field mapping definition
271
272
Features:
273
- Automated data import rules
274
- Field mapping configuration
275
- Data validation rules
276
- Error handling setup
277
"""
278
279
def geolocation(**options):
280
"""
281
Manage geolocation data and address geocoding.
282
283
Parameters:
284
- action: str, operation to perform (update, import, export)
285
- provider: str, geocoding service provider
286
- batch_size: int, processing batch size
287
288
Operations:
289
- Geocode existing addresses
290
- Import geographic data
291
- Update location coordinates
292
- Manage map service integration
293
"""
294
```
295
296
## Usage Examples
297
298
### Basic Server Operations
299
300
```python
301
# Start development server
302
from creme.manage import execute
303
import sys
304
sys.argv = ['creme', 'runserver', '8000']
305
execute()
306
307
# Run database migrations
308
sys.argv = ['creme', 'migrate']
309
execute()
310
311
# Collect static files
312
sys.argv = ['creme', 'collectstatic', '--noinput']
313
execute()
314
```
315
316
### Database Setup
317
318
```python
319
# Initialize database with default data
320
sys.argv = ['creme', 'creme_populate', '--verbosity=2']
321
execute()
322
323
# Create admin user
324
sys.argv = ['creme', 'creme_createstaffuser']
325
execute() # Will prompt for username, email, password
326
327
# Create user with specific role
328
sys.argv = ['creme', 'creme_createstaffuser',
329
'--username=admin', '--email=admin@example.com',
330
'--role=Administrator']
331
execute()
332
```
333
334
### Job Management
335
336
```python
337
# Start job processing
338
sys.argv = ['creme', 'creme_job_manager', 'start']
339
execute()
340
341
# Check job queue status
342
sys.argv = ['creme', 'creme_job_manager', 'status']
343
execute()
344
345
# Clear completed jobs
346
sys.argv = ['creme', 'creme_job_manager', 'clear', '--completed']
347
execute()
348
```
349
350
### Development Tools
351
352
```python
353
# Generate test data
354
sys.argv = ['creme', 'entity_factory', '--entity_type=Contact', '--count=100']
355
execute()
356
357
# Generate secret key
358
sys.argv = ['creme', 'build_secret_key', '--length=50']
359
execute()
360
361
# Check translations
362
sys.argv = ['creme', 'i18n_empty', '--locale=fr']
363
execute()
364
```
365
366
## Environment Configuration
367
368
### Required Environment Variables
369
370
```python
371
# Django settings module (optional, has default)
372
os.environ['DJANGO_SETTINGS_MODULE'] = 'creme.settings'
373
374
# Database configuration (in settings or environment)
375
os.environ['DATABASE_URL'] = 'postgresql://user:pass@localhost/creme_db'
376
377
# Redis configuration for job queue
378
os.environ['REDIS_URL'] = 'redis://localhost:6379/0'
379
380
# Media and static files
381
os.environ['MEDIA_ROOT'] = '/var/creme/media'
382
os.environ['STATIC_ROOT'] = '/var/creme/static'
383
```
384
385
### Optional Configuration
386
387
```python
388
# Coverage tracking for tests
389
os.environ['COVERAGE_PROCESS_START'] = '.coveragerc'
390
391
# Debug mode
392
os.environ['DEBUG'] = 'True'
393
394
# Email configuration
395
os.environ['EMAIL_HOST'] = 'smtp.example.com'
396
os.environ['EMAIL_PORT'] = '587'
397
os.environ['EMAIL_HOST_USER'] = 'noreply@example.com'
398
os.environ['EMAIL_HOST_PASSWORD'] = 'password'
399
```
400
401
## Command-Line Integration
402
403
The console interface integrates with system package managers and deployment tools:
404
405
```bash
406
# Install and initialize
407
pip install creme-crm
408
creme migrate
409
creme creme_populate
410
creme creme_createstaffuser
411
412
# Start server
413
creme runserver 0.0.0.0:8000
414
415
# Production deployment
416
creme collectstatic --noinput
417
creme migrate --run-syncdb
418
creme creme_job_manager start
419
420
# Maintenance tasks
421
creme clearsessions
422
creme cleanup_files
423
creme i18n_duplicates --locale=all
424
```