API Documentation

Command

Documentation corresponding to Command class of generate_settings

class django_settings_custom.management.commands.generate_settings.Command(*argc, **kwargs)

A Django interactive command for configuration file generation.

Example

python manage.py generate_settings path/to/template/settings.ini target/path/of/settings.ini’

settings_template_file

Path to the settings template file.

Type:str
settings_file_path

Target path for the created settings file.

Type:str
force_secret_key

Generate SECRET_KEY without asking ?

Type:bool
add_arguments(parser)

Add custom arguments to the command. See python manage.py generate_settings –help.

get_value(section, key, value_type)

Get a value for the [section] key passed as parameter.

Parameters:
  • section (str) – Section in the configuration file.
  • key (str) – Key in the configuration file.
  • value_type (str) – Value type read in template, must be “DJANGO_SECRET_KEY”, “USER_VALUE” or “ENCRYPTED_USER_VALUE”.
Returns:

Value for the [section] key

Return type:

int or str

handle(*args, **options)

Command core.

Encryption

Documentation corresponding to encryption.py

django_settings_custom.encryption.decrypt(source, secret_key=None)

Decrypt the source with the key passed as parameter.

Parameters:
  • source (str or byte string) – A string or a bytes array to decrypt.
  • secret_key (str) – The key for encryption, or None if you want use the SECRET_KEY.
Returns:

Decrypted value.

Return type:

str

If the secret_key is not provided, it uses Django settings.SECRET_KEY.

django_settings_custom.encryption.encrypt(source, secret_key=None)

Encrypt the source with the key passed as parameter.

Parameters:
  • source (str or byte string) – A string or a bytes array to encrypt.
  • secret_key (str) – The key for encryption, or None if you want use the SECRET_KEY.
Returns:

Encrypted value.

Return type:

str

If the secret_key is not provided, it uses Django settings.SECRET_KEY.