1

I need to run a Python Django project with PyCharm IDE locally using HTTPS so that other services can talk with my service without errors.

I need help managing to run it locally in HTTPS.

Yevgeniy Kosmak
  • 3,561
  • 2
  • 10
  • 26
Nadav
  • 2,589
  • 9
  • 44
  • 63

1 Answers1

3

You can use runserver_plus extension. It depends on Werkzeug, so you have to install it first. Installation:

pip install Werkzeug
pip install django-extensions
pip install pyOpenSSL

Then add django_extensions to your INSTALLED_APPS inside settings.py:

INSTALLED_APPS = (
    ...
    'django_extensions',
)

Now you need to generate self-signed certificate for your local server. Something like this, credits to Diego Woitasen:

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365

And now you can run Django this way:

python manage.py runserver_plus --cert-file /path/to/cert.crt

And some links for sources:

Yevgeniy Kosmak
  • 3,561
  • 2
  • 10
  • 26