Sunday, July 7, 2019

Django with Djongo on Jupyter Notebook

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. 






Saturday, July 6, 2019

Django with Mongodb Environment set-up

Django + MongoDB = Djongo on Jupyter Notebook

Now a days Python is widespread that each software engineer try and add in their illustrious language list. However, why Python and why it’s popular? - I think there's major three reason behind that
  1. Easy to learn
  2. Easy to code
  3. Rich Library Packages
Generally I noticed python is used as back-end. I was a web and mobile app developer, so my thought was why can't we use python as full stack development? - And I found Django -It is a Python Web framework via mastering I received to understand that Django also support MongoDB as Database. I am going to describe how to set Django with MongoDB.


Install Python  

Make sure python 3.x installed. (click here)

Check Installed Python Version

Window Key---- Type cmd ---- Enter key ---- type 'python -V'

Install MongoDB

Install Django

pip install django


Install Djongo

pip install djongo


Did you see the Jupyter image? – Yes, It’s symbol of Jupyter Notebook. The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text.


In my Next Blog, I will describe about How to build Django + mongodb web application on Jupyter Notebook. Stay tuned…