Django SECRET_KEY need for providing cryptographic signing (documentation). This value is stored in
These steps help you for generating new SECRET_KEY value:
Activate your project's virtual environment:
source env/bin/activate
Enter in Django's manage.py shell:
python3 manage.py shell
Import get_random_secret_key() function:
from django.core.management.utils import get_random_secret_key
Just call get_random_secret_key() function:
get_random_secret_key()
Full example:
user@localhost:~/demo$ source env/bin/activate (env) user@localhost:~/demo$ python3 manage.py shell Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from django.core.management.utils import get_random_secret_key >>> get_random_secret_key() '(#jdao11q1)kw1rs40z2$b^kntmw3ts9)wg2r*zk3z0_^t&hha'
Are my posts is helpful? You may support me on Patreon.
The above is the detailed content of Generating SECRET_KEY for production deployment of Django project. For more information, please follow other related articles on the PHP Chinese website!