Use the `generate_secret_key` command of `django_extensions` instead of Python code.