Hi
Folks, Thanks for staying tuned. This blog is about “How to use Jupyter
Notebook for Django web application development?”.
However,
before beginning with Jupyter set-up, let’s see some benefits about “Why I select Jupyter for my code development?”.
1. Contain live code, equations, visualizations and
explanatory text
2. It is literate programming, where you can check
your code line by line.
1. Ex. If you add one for loop, you can check that ‘for
loop’ output by pressing Shift + Enter key.
3. Don’t need to run the whole file to check 'for loop' output.
4. You can add markdown cell to feature text regarding code rather than comment.
5. Don’t need to remember different comment tags like #, <!--->, // etc.
It's so Amazing!! |
Let’s
set-up Jupyter by following below cmd.
pip
install jupyter ipython
To
add Django into Jupyter Notebook
pip
install django-extensions
So
our environment set-up is ready. Now we can start with our first Hello World
Django project, with mongoDB as database on Jupyter Notebook.
Create
hello_world project
Django-admin
startproject hello_world
Go
to the hello_world directory inside hello_world project directory then append
django_extensions in file settings.py under INSTALLED_APPS section.
INSTALLED_APPS
= [
...
'django_extensions',
]
And
then get back to parent folder and run jupyter notebook.
python manage.py shell_plus --notebook
Jupyter Notebook in Browser |
After
that create a jupyter notebook file by clicking New -> Django Shell-Plus and
type a simple command and press Shift + Enter Key.
Print cmd in Jupyter |
Open
settings.py which is inside hello_world and add Djongo in database configuration
to set mongodb as database.
settings.py open in Jupyter |
Now
let’s run Django app server.
Python manage.py runserver
Default Web Page of Hello_World project |
Hurray!
You are now ready to build a Django web application with mongoDB database on
Jupyter Notebook.
Hurrah! we did it |
Thanks for being patient. I accept your valuable feedback, Feel free to write a comment.