diff --git a/scripts/_common.sh b/scripts/_common.sh
index 0e3da73..b95ce9c 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -20,6 +20,12 @@ final_path=/opt/yunohost/$app
 log_path=/var/log/$app
 log_file="${log_path}/django_example_ynh.log"
 
+# XXX: Is this okay?
+adminmail="${admin}@${domain}"
+
+# Default: settings.DEBUG=False
+django_debug="False"
+
 #=================================================
 # COMMON VARIABLES
 #=================================================
diff --git a/scripts/change_url b/scripts/change_url
index 2b32057..70da8ea 100644
--- a/scripts/change_url
+++ b/scripts/change_url
@@ -113,29 +113,9 @@ fi
 #=================================================
 # MODIFY SETTINGS
 #=================================================
-ynh_script_progression --message="Modify PyInventory's config file..."
+ynh_script_progression --message="Modify django_example_ynh's config file..."
 
-# save old settings file
-settings="$final_path/settings.py"
-ynh_backup_if_checksum_is_different --file="$settings"
-
-cp "../conf/settings.py" "$settings"
-
-ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$settings"
-ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings"
-ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$settings"
-ynh_replace_string --match_string="__ADMINMAIL__" --replace_string="$admin_mail" --target_file="$settings"
-ynh_replace_string --match_string="__FINAL_HOME_PATH__" --replace_string="$final_path" --target_file="$settings"
-ynh_replace_string --match_string="__FINAL_WWW_PATH__" --replace_string="$public_path" --target_file="$settings"
-ynh_replace_string --match_string="__LOG_FILE__" --replace_string="$log_file" --target_file="$settings"
-ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$settings"
-
-# Difference to install/upgrade scripts: Use $new_domain and $new_path here:
-ynh_replace_string --match_string="__DOMAIN__" --replace_string="$new_domain" --target_file="$settings"
-ynh_replace_string --match_string="__PATH_URL__" --replace_string="$new_path" --target_file="$settings"
-
-# Recalculate and store the config file checksum into the app settings
-ynh_store_file_checksum --file="$settings"
+ynh_add_config --template="settings.py" --destination="$final_path/settings.py"
 
 #=================================================
 # GENERIC FINALISATION
diff --git a/scripts/install b/scripts/install
index 8f51147..279909e 100755
--- a/scripts/install
+++ b/scripts/install
@@ -56,7 +56,12 @@ ynh_app_setting_set --app="$app" --key=port --value="$port"
 
 db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
 admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
+
 redis_db=$(ynh_redis_get_free_db)
+ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
+
+# Always deactivate settings.DEBUG:
+ynh_app_setting_set --app=$app --key=django_debug --value="False"
 
 #=================================================
 # STANDARD MODIFICATIONS
@@ -127,45 +132,16 @@ chown -R "$app:" "$final_path"
 # ================================================
 ynh_script_progression --message="Create project configuration files..."
 
-gunicorn_conf="$final_path/gunicorn.conf.py"
-cp "../conf/gunicorn.conf.py" "$gunicorn_conf"
-ynh_replace_string --match_string="__FINAL_HOME_PATH__" --replace_string="$final_path" --target_file="$gunicorn_conf"
-ynh_replace_string --match_string="__LOG_FILE__" --replace_string="$log_file" --target_file="$gunicorn_conf"
-ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$gunicorn_conf"
-ynh_store_file_checksum --file="$gunicorn_conf"
+ynh_add_config --template="gunicorn.conf.py" --destination="$final_path/gunicorn.conf.py"
 
-cp ../conf/manage.py "$final_path/manage.py"
-ynh_replace_string --match_string="__FINAL_HOME_PATH__" --replace_string="$final_path" --target_file="$final_path/manage.py"
-ynh_store_file_checksum --file="$final_path/manage.py"
+ynh_add_config --template="manage.py" --destination="$final_path/manage.py"
 chmod +x "$final_path/manage.py"
 
-settings="$final_path/settings.py"
-cp "../conf/settings.py" "$settings"
-
-ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$settings"
-ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$settings"
-ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$settings"
-ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings"
-ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$settings"
-ynh_replace_string --match_string="__ADMINMAIL__" --replace_string="$admin_mail" --target_file="$settings"
-ynh_replace_string --match_string="__FINAL_HOME_PATH__" --replace_string="$final_path" --target_file="$settings"
-ynh_replace_string --match_string="__FINAL_WWW_PATH__" --replace_string="$public_path" --target_file="$settings"
-ynh_replace_string --match_string="__LOG_FILE__" --replace_string="$log_file" --target_file="$settings"
-ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$settings"
-
-ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$settings"
-ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="$settings"
-
-# Calculate and store the config file checksum into the app settings
-ynh_store_file_checksum --file="$settings"
-
-ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
-
-cp ../conf/setup_user.py "$final_path/setup_user.py"
-cp ../conf/urls.py "$final_path/urls.py"
-cp ../conf/wsgi.py "$final_path/wsgi.py"
-
-touch "$final_path/local_settings.py"
+ynh_add_config --template="settings.py" --destination="$final_path/settings.py"
+ynh_add_config --template="setup_user.py" --destination="$final_path/setup_user.py"
+ynh_add_config --template="urls.py" --destination="$final_path/urls.py"
+ynh_add_config --template="wsgi.py" --destination="$final_path/wsgi.py"
+ynh_add_config --template="local_settings.py" --destination="$final_path/local_settings.py"
 
 #=================================================
 # MIGRATE / COLLECTSTATIC / CREATEADMIN
@@ -242,7 +218,7 @@ fi
 #=================================================
 # Start django_example_ynh via systemd
 #=================================================
-ynh_script_progression --message="Starting PyInventory's services..." --weight=5
+ynh_script_progression --message="Starting django_example_ynh's services..." --weight=5
 
 ynh_systemd_action --service_name="$app" --action="start"
 
diff --git a/scripts/upgrade b/scripts/upgrade
index b07d1c9..c7292a0 100755
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -22,10 +22,16 @@ domain=$(ynh_app_setting_get --app="$app" --key=domain)
 path_url=$(ynh_app_setting_get --app="$app" --key=path)
 
 port=$(ynh_app_setting_get --app="$app" --key=port)
+
 db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
+db_name=$(ynh_sanitize_dbid --db_name="$app")
+db_user=$db_name
+
 admin_mail=$(ynh_user_get_info "$admin" mail)
 redis_db=$(ynh_app_setting_get --app="$app" --key=redis_db)
 
+django_debug=$(ynh_app_setting_get --app="$app" --key=django_debug)
+
 #=================================================
 # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
 #=================================================
@@ -49,6 +55,13 @@ ynh_script_progression --message="Stopping systemd services..." --weight=5
 
 ynh_systemd_action --service_name="$app" --action="stop"
 
+#=================================================
+# Manage old settings
+#=================================================
+
+# Always deactivate settings.DEBUG:
+ynh_app_setting_set --app=$app --key=django_debug --value="False"
+
 #=================================================
 # NGINX CONFIGURATION
 #=================================================
@@ -111,74 +124,37 @@ chown -R "$app:" "$final_path"
 # ================================================
 ynh_script_progression --message="Create project configuration files..."
 
-gunicorn_conf="$final_path/gunicorn.conf.py"
-ynh_backup_if_checksum_is_different --file="$gunicorn_conf"
-cp "../conf/gunicorn.conf.py" "$gunicorn_conf"
-ynh_replace_string --match_string="__FINAL_HOME_PATH__" --replace_string="$final_path" --target_file="$gunicorn_conf"
-ynh_replace_string --match_string="__LOG_FILE__" --replace_string="$log_file" --target_file="$gunicorn_conf"
-ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$gunicorn_conf"
-ynh_store_file_checksum --file="$gunicorn_conf"
+ynh_add_config --template="gunicorn.conf.py" --destination="$final_path/gunicorn.conf.py"
 
-ynh_backup_if_checksum_is_different --file="$final_path/manage.py"
-cp ../conf/manage.py "$final_path/manage.py"
+ynh_add_config --template="manage.py" --destination="$final_path/manage.py"
 chmod +x "$final_path/manage.py"
 
-# save old settings file
-settings="$final_path/settings.py"
-ynh_backup_if_checksum_is_different --file="$settings"
-
-cp "../conf/settings.py" "$settings"
-
-ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$settings"
-ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings"
-ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$settings"
-ynh_replace_string --match_string="__ADMINMAIL__" --replace_string="$admin_mail" --target_file="$settings"
-ynh_replace_string --match_string="__FINAL_HOME_PATH__" --replace_string="$final_path" --target_file="$settings"
-ynh_replace_string --match_string="__FINAL_WWW_PATH__" --replace_string="$public_path" --target_file="$settings"
-ynh_replace_string --match_string="__LOG_FILE__" --replace_string="$log_file" --target_file="$settings"
-ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$settings"
-
-ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$settings"
-ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="$settings"
-
-# Recalculate and store the config file checksum into the app settings
-ynh_store_file_checksum --file="$settings"
-
-ynh_backup_if_checksum_is_different --file="$final_path/setup_user.py"
-cp ../conf/setup_user.py "$final_path/setup_user.py"
-
-ynh_backup_if_checksum_is_different --file="$final_path/urls.py"
-cp ../conf/urls.py "$final_path/urls.py"
-
-ynh_backup_if_checksum_is_different --file="$final_path/wsgi.py"
-cp ../conf/wsgi.py "$final_path/wsgi.py"
-
-touch "$final_path/local_settings.py"
+ynh_add_config --template="settings.py" --destination="$final_path/settings.py"
+ynh_add_config --template="setup_user.py" --destination="$final_path/setup_user.py"
+ynh_add_config --template="urls.py" --destination="$final_path/urls.py"
+ynh_add_config --template="wsgi.py" --destination="$final_path/wsgi.py"
+ynh_add_config --template="local_settings.py" --destination="$final_path/local_settings.py"
 
 #=================================================
 # MIGRATE PYINVENTORY
 #=================================================
 ynh_script_progression --message="migrate/collectstatic/createadmin..." --weight=10
 
-(
-	set +o nounset
-	source "${final_path}/venv/bin/activate"
-	set -o nounset
-	cd "${final_path}"
+cd "$final_path" || exit
 
-  # Just for debugging:
-  ./manage.py diffsettings
+# Just for debugging:
+./manage.py diffsettings
 
-	./manage.py migrate --no-input
-	./manage.py collectstatic --no-input
+./manage.py migrate --no-input
+./manage.py collectstatic --no-input
 
-	# Create/update Django superuser (set unusable password, because auth done via SSOwat):
-	./manage.py create_superuser --username="$admin" --email="$admin_mail"
+# Create/update Django superuser (set unusable password, because auth done via SSOwat):
+./manage.py create_superuser --username="$admin" --email="$admin_mail"
+
+# Check the configuration
+# This may fail in some cases with errors, etc., but the app works and the user can fix issues later.
+./manage.py check --deploy || true
 
-	# Check the configuration
-	# This may fail in some cases with errors, etc., but the app works and the user can fix issues later.
-	./manage.py check --deploy || true
-)
 
 #=================================================
 # SETUP LOGROTATE
@@ -213,7 +189,7 @@ chmod o-rwx "$final_path"
 #=================================================
 # Start django_example_ynh via systemd
 #=================================================
-ynh_script_progression --message="Starting PyInventory's services..." --weight=5
+ynh_script_progression --message="Starting django_example_ynh's services..." --weight=5
 
 ynh_systemd_action --service_name="$app" --action="start"