From 22e1972e9eb705a4cf0522edfe9aa709f8e87ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20Wersd=C3=B6rfer?= Date: Fri, 17 Nov 2023 17:21:51 +0100 Subject: [PATCH] make jupyter notebook work again --- Procfile | 2 +- example/settings.py | 21 +++++++++++++++++++++ pyproject.toml | 5 ++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Procfile b/Procfile index 44224ae..e0776b8 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ django: PYTHONUNBUFFERED=true python manage.py runserver --settings example.settings 0.0:8000 -jupyterlab: DJANGO_ALLOW_ASYNC_UNSAFE=true python manage.py shell_plus --notebook +jupyterlab: DJANGO_ALLOW_ASYNC_UNSAFE=true python manage.py shell_plus --settings example.settings --notebook diff --git a/example/settings.py b/example/settings.py index 1e9443a..65c9d8f 100644 --- a/example/settings.py +++ b/example/settings.py @@ -83,6 +83,27 @@ # See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url MEDIA_URL = "/media/" +# Jupyter notebook stuff +PATH_TO_NOTEBOOK_DIR = "notebooks" +try: + import jupyterlab # noqa + + notebook_default_url = "/lab" # Using JupyterLab +except ImportError: + notebook_default_url = "/tree" # Using Jupyter + +NOTEBOOK_ARGUMENTS = [ + "--ip", + "127.0.0.1", + "--port", + "8888", + "--notebook-dir", + PATH_TO_NOTEBOOK_DIR, + "--NotebookApp.default_url", + notebook_default_url, +] +IPYTHON_KERNEL_DISPLAY_NAME = "Django Kernel" + # TEMPLATE CONFIGURATION # ------------------------------------------------------------------------------ diff --git a/pyproject.toml b/pyproject.toml index 970c842..346ad11 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,10 +49,13 @@ dev = [ "django_extensions", "isort", "jupyter", - "jupyter-server", + "jupyterlab", + "jupyter-server < 2.0.0", + "notebook", "pyzmq >= 25.1.1", "setuptools", "tox", + "traitlets < 5.10.0", # https://github.com/microsoft/azuredatastudio/issues/24436 - jupyterlab wont work "typer", ]