15 Jun 2020

How to start Django

  • django
  • setup
  • python
  • I have created Helloworld web app that includes todo list to practice basic web app development

    Django

    Django is a server-side Python web framework. <img src = “django.png” width = 70%/>

    Set-Up Django for MacOS

    Django Development Environment includes Python scripts and a simple development webserver that you can test local Djnago web applications on web browser. (reference)

    1. Install Python

    python 3.8.2

    Homebrew is an open-source software package manager that helps install different applications on MacOS

    $brew install python3

    2. Install Pipenv

    Pipenv is a tool that automatically creates and manages a virtual environment for Python. We need a virtual environment to keep dependencies required by different projects separate by creating isolated python virtual environments for them. Pipenv prevents having to use pip and virtualenv separately. ( GeeksForGeeks )

    $pip3 install pipenv
    pip3 is automatically installed by Homebrew. Pip3 is another package manager that includes pipenv

    3. Move to a directory and create a folder for the new project

    $mkdir helloworld_webapp
    $cd helloworld_webapp
    

    4. Install django with pipenv

    Pipenv creates a virtual environment django of 2.1 version speicifically for this project.

    $pipenv instal django==2.1

    5. Activate the virtual environment

    $pipenv shell

    This allows you to use the specific version of django that you installed for your project.

    6. Create a new project

    $django-admin startproject helloworld_project .

    This starts a new project, helloworld_project in the current directory.

    Now you can run django server $python manage.py runserver and open the local host to view your project on web browser!