Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow notebooks in other locations #162

Merged
merged 6 commits into from
Mar 2, 2024

Conversation

nmpowell
Copy link
Contributor

@nmpowell nmpowell commented Feb 14, 2024

Currently dj-notebook assumes your Jupyter Notebooks are stored in the same directory as your Django project.

This PR allows you to store your Notebooks in a separate directory, for example if you don't want to add them to source control, or you organise your notebooks separately.

It adds a search_dir param to activate (as in, plus.activate(search_dir=...)), enabling the following usage:

from dj_notebook import activate

plus = activate(search_dir=/home/username/your-django-project/src")

This piggybacks on the existing function find_django_settings_module searching parents and immediate children of the supplied directory. Thus if your manage.py is in the above src directory, you can also use search_dir=/home/username/your-django-project" or search_dir=/home/username/your-django-project/src/subdir". If no search_dir is supplied, it retains the existing functionality of using Path.cwd().

A couple of minor tweaks also included in separate commits.

@nmpowell nmpowell force-pushed the allow-notebooks-in-other-locations branch 2 times, most recently from 9b134df to 2eb64be Compare February 14, 2024 13:15
@nmpowell nmpowell force-pushed the allow-notebooks-in-other-locations branch from 2eb64be to d9cdafe Compare February 14, 2024 13:37
@pydanny
Copy link
Owner

pydanny commented Feb 29, 2024

Hey @nmpowell! I just saw this PR, sorry I didn't look at it earlier. I'll review it first thing tomorrow when I'm fresh and ready to take a good look. 😄

Copy link
Owner

@pydanny pydanny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Looks really good. Thanks so much for this contribution!

@pydanny pydanny merged commit 1ed3c2d into pydanny:main Mar 2, 2024
@pydanny
Copy link
Owner

pydanny commented Mar 2, 2024

PyPI release done: https://pypi.org/project/dj-notebook/0.7.0/

You're now in the list of contributors!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants