or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

activity-system.mdapi-integration.mdbilling-system.mdconfiguration-system.mdconsole-interface.mdcontact-management.mdcore-framework.mddjango-settings.mddocument-management.mdemail-system.mdevent-system.mdimport-export-system.mdindex.mdmanagement-commands.mdplugin-development.mdproduct-catalog.mdreporting-system.mdsales-management.mdsystem-configuration.mdtemplate-system.mdticket-system.mduser-management.md

django-settings.mddocs/

0

# Django Settings

1

2

Configuration system for Creme CRM with database, security, internationalization, media handling, and application-specific settings.

3

4

## Capabilities

5

6

### Database Configuration

7

8

Database connection and behavior settings.

9

10

```python { .api }

11

DATABASES = {

12

'default': {

13

'ENGINE': 'django.db.backends.postgresql',

14

'NAME': 'creme_crm',

15

'USER': 'creme_user',

16

'PASSWORD': 'password',

17

'HOST': 'localhost',

18

'PORT': '5432',

19

'OPTIONS': {

20

'charset': 'utf8',

21

},

22

}

23

}

24

25

# Auto-incrementing field configuration

26

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

27

28

# Database connection timeout

29

DATABASE_CONNECTION_TIMEOUT = 600

30

```

31

32

### Authentication & Security

33

34

User authentication and security configuration.

35

36

```python { .api }

37

# Custom user model

38

AUTH_USER_MODEL = 'creme_core.CremeUser'

39

40

# Authentication backends

41

AUTHENTICATION_BACKENDS = [

42

'creme.creme_core.backends.CremeBackend',

43

'django.contrib.auth.backends.ModelBackend',

44

]

45

46

# Security settings

47

SECRET_KEY = 'your-secret-key-here'

48

DEBUG = False

49

ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'your-domain.com']

50

51

# Session configuration

52

SESSION_COOKIE_AGE = 3600 # 1 hour

53

SESSION_SAVE_EVERY_REQUEST = True

54

SESSION_EXPIRE_AT_BROWSER_CLOSE = True

55

```

56

57

### Media & File Handling

58

59

File upload and static file configuration.

60

61

```python { .api }

62

# Media files (user uploads)

63

MEDIA_ROOT = '/var/creme/media'

64

MEDIA_URL = '/media/'

65

66

# Static files

67

STATIC_ROOT = '/var/creme/static'

68

STATIC_URL = '/static/'

69

STATICFILES_DIRS = [

70

os.path.join(BASE_DIR, 'static'),

71

]

72

73

# File upload restrictions

74

ALLOWED_IMAGES_EXTENSIONS = ['jpg', 'jpeg', 'png', 'gif', 'bmp']

75

ALLOWED_EXTENSIONS = ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'txt', 'csv']

76

MAX_UPLOAD_SIZE = 10 * 1024 * 1024 # 10 MB

77

78

# File storage backend

79

DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'

80

```

81

82

### Job System Configuration

83

84

Background job processing settings.

85

86

```python { .api }

87

# Job processing limits

88

MAX_JOBS_PER_USER = 2

89

PSEUDO_PERIOD = [1, 2, 3, 4] # Job execution intervals

90

91

# Redis broker for job queue

92

JOBMANAGER_BROKER = {

93

'HOST': 'localhost',

94

'PORT': 6379,

95

'DB': 0,

96

'PASSWORD': None,

97

}

98

99

# Job timeout settings

100

JOB_TIMEOUT = 3600 # 1 hour default timeout

101

LONG_JOB_TIMEOUT = 7200 # 2 hours for long operations

102

```

103

104

### Application Configuration

105

106

Creme-specific application settings.

107

108

```python { .api }

109

# Installed Django applications

110

INSTALLED_DJANGO_APPS = [

111

'django.contrib.auth',

112

'django.contrib.contenttypes',

113

'django.contrib.sessions',

114

'django.contrib.messages',

115

'django.contrib.staticfiles',

116

# ... other Django apps

117

]

118

119

# Installed Creme applications

120

INSTALLED_CREME_APPS = [

121

'creme.creme_core',

122

'creme.persons',

123

'creme.activities',

124

'creme.billing',

125

'creme.opportunities',

126

'creme.commercial',

127

'creme.documents',

128

'creme.emails',

129

'creme.products',

130

'creme.reports',

131

# ... other Creme apps

132

]

133

134

INSTALLED_APPS = INSTALLED_DJANGO_APPS + INSTALLED_CREME_APPS

135

136

# Data population configuration

137

POPULATORS = [

138

'creme.creme_core.populators',

139

'creme.persons.populators',

140

'creme.activities.populators',

141

# ... other populators

142

]

143

```

144

145

### Model Configuration

146

147

Dynamic model settings for customization.

148

149

```python { .api }

150

# Configurable model settings

151

PERSONS_CONTACT_MODEL = 'persons.Contact'

152

PERSONS_ORGANISATION_MODEL = 'persons.Organisation'

153

ACTIVITIES_ACTIVITY_MODEL = 'activities.Activity'

154

BILLING_INVOICE_MODEL = 'billing.Invoice'

155

BILLING_QUOTE_MODEL = 'billing.Quote'

156

DOCUMENTS_DOCUMENT_MODEL = 'documents.Document'

157

158

# Core system models

159

CREME_CORE_WSETTINGS_MODEL = 'creme_core.WorldSettings'

160

```

161

162

### Email Configuration

163

164

Email backend and SMTP settings.

165

166

```python { .api }

167

# Email backend

168

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

169

170

# SMTP configuration

171

EMAIL_HOST = 'smtp.gmail.com'

172

EMAIL_PORT = 587

173

EMAIL_USE_TLS = True

174

EMAIL_HOST_USER = 'your-email@gmail.com'

175

EMAIL_HOST_PASSWORD = 'your-password'

176

177

# Default sender information

178

DEFAULT_FROM_EMAIL = 'noreply@yourcompany.com'

179

SERVER_EMAIL = 'admin@yourcompany.com'

180

```

181

182

### Internationalization

183

184

Language and localization settings.

185

186

```python { .api }

187

# Language configuration

188

LANGUAGE_CODE = 'en'

189

LANGUAGES = [

190

('en', 'English'),

191

('fr', 'Français'),

192

('es', 'Español'),

193

('de', 'Deutsch'),

194

]

195

196

# Timezone configuration

197

TIME_ZONE = 'UTC'

198

USE_TZ = True

199

USE_I18N = True

200

USE_L10N = True

201

202

# Translation files location

203

LOCALE_PATHS = [

204

os.path.join(BASE_DIR, 'locale'),

205

]

206

```

207

208

## Usage Examples

209

210

### Basic Configuration

211

212

```python

213

# settings.py for development

214

import os

215

216

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

217

218

# Database for development

219

DATABASES = {

220

'default': {

221

'ENGINE': 'django.db.backends.sqlite3',

222

'NAME': os.path.join(BASE_DIR, 'creme.sqlite3'),

223

}

224

}

225

226

# Debug mode

227

DEBUG = True

228

ALLOWED_HOSTS = ['localhost', '127.0.0.1']

229

230

# Media and static files

231

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

232

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

233

```

234

235

### Production Configuration

236

237

```python

238

# settings.py for production

239

import os

240

from pathlib import Path

241

242

# Security settings

243

DEBUG = False

244

SECRET_KEY = os.environ.get('SECRET_KEY')

245

ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '').split(',')

246

247

# Database from environment

248

DATABASES = {

249

'default': {

250

'ENGINE': 'django.db.backends.postgresql',

251

'NAME': os.environ.get('DB_NAME'),

252

'USER': os.environ.get('DB_USER'),

253

'PASSWORD': os.environ.get('DB_PASSWORD'),

254

'HOST': os.environ.get('DB_HOST', 'localhost'),

255

'PORT': os.environ.get('DB_PORT', '5432'),

256

}

257

}

258

259

# Redis configuration

260

JOBMANAGER_BROKER = {

261

'HOST': os.environ.get('REDIS_HOST', 'localhost'),

262

'PORT': int(os.environ.get('REDIS_PORT', '6379')),

263

'DB': int(os.environ.get('REDIS_DB', '0')),

264

'PASSWORD': os.environ.get('REDIS_PASSWORD'),

265

}

266

267

# File storage

268

MEDIA_ROOT = '/var/creme/media'

269

STATIC_ROOT = '/var/creme/static'

270

```

271

272

### Custom Model Configuration

273

274

```python

275

# Using custom models

276

PERSONS_CONTACT_MODEL = 'my_app.CustomContact'

277

PERSONS_ORGANISATION_MODEL = 'my_app.CustomOrganisation'

278

279

# Ensure custom apps are installed

280

INSTALLED_CREME_APPS = [

281

'creme.creme_core',

282

'my_app', # Custom app with models

283

'creme.persons',

284

# ... other apps

285

]

286

```

287

288

### Email Configuration Examples

289

290

```python

291

# Gmail SMTP

292

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

293

EMAIL_HOST = 'smtp.gmail.com'

294

EMAIL_PORT = 587

295

EMAIL_USE_TLS = True

296

EMAIL_HOST_USER = 'your-email@gmail.com'

297

EMAIL_HOST_PASSWORD = 'your-app-password'

298

299

# Amazon SES

300

EMAIL_BACKEND = 'django_ses.SESBackend'

301

AWS_ACCESS_KEY_ID = 'your-access-key'

302

AWS_SECRET_ACCESS_KEY = 'your-secret-key'

303

AWS_SES_REGION_NAME = 'us-east-1'

304

305

# Console backend for development

306

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

307

```

308

309

### Advanced Configuration

310

311

```python

312

# Logging configuration

313

LOGGING = {

314

'version': 1,

315

'disable_existing_loggers': False,

316

'handlers': {

317

'file': {

318

'level': 'INFO',

319

'class': 'logging.FileHandler',

320

'filename': '/var/log/creme/creme.log',

321

},

322

'console': {

323

'level': 'DEBUG',

324

'class': 'logging.StreamHandler',

325

},

326

},

327

'root': {

328

'handlers': ['console', 'file'],

329

'level': 'INFO',

330

},

331

}

332

333

# Cache configuration

334

CACHES = {

335

'default': {

336

'BACKEND': 'django_redis.cache.RedisCache',

337

'LOCATION': 'redis://127.0.0.1:6379/1',

338

'OPTIONS': {

339

'CLIENT_CLASS': 'django_redis.client.DefaultClient',

340

}

341

}

342

}

343

344

# Session configuration

345

SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'

346

SESSION_CACHE_ALIAS = 'default'

347

```