Force SSL for Django Postgres connection

前端 未结 3 1898
一整个雨季
一整个雨季 2021-02-07 03:13

I want to force Django to use SSL to connect to my postgres database.

This question indicates that I need to pass sslmode=\'require\' to the psycopg2 connec

3条回答
  •  南方客
    南方客 (楼主)
    2021-02-07 03:23

    If you're using dj_database_url you can pass ssl_require=True which sets the option for you.

    import dj_database_url
    DATABASES['default'] = dj_database_url.config(ssl_require=True)
    

提交回复
热议问题