Python - Django

Image

Django Project - where to start

march - 2024

Programming

Summery

My wife and I have busy schedules, and I wanted to have a place where we could both easily access a centralized schedule, check on our budget in an easy-to-view view, save recipes for our favorite meals, and more. I have always liked the Raspberry Pi magic mirror idea but wanted to make it my own with a custom dashboard that met my family's needs. Because of this, I dug into Django, Python's web-based development platform. create Virtual EnvironmentOn my Journey, I knew it would be important to gain an understanding of a programming language and decided on Python due to its rising popularity and versatility. I started with simple console games to learn the basic structure of Python, along with reading and modifying some prebuilt OS scripts for moving files and resizing pictures.

My wife and I have busy schedules, and I wanted to have a place where we could both easily access a centralized schedule, check on our budget in an easy-to-view view, save recipes for our favorite meals, and more. I have always liked the Raspberry Pi magic mirror idea but wanted to make it my own with a custom dashboard that met my family's needs. Because of this, I dug into Django, Python's web-based development platform. create Virtual Environment

Starting Goals

  • Create Virtual Environment
  • Install Django
  • Create Project
Run django

started by reading a few articles on Django Basics. I found that Python has a built-in virtual environment feature that allows for the installation of packages in a unique environment without it installing on my full system. This allows me to install Django in a separate environment (folder) and potentially additional items unique to my project.
  • Open the command prompt and cd into my project folder
    • (for me) cd c:\py
  • Create my virtual environment (venv) folder and activatefrom here, all my Python commands will only affect the Django-project file, meaning I will need to install Django and start a project.
    • python -m venv django-project
    • cd jango-project (you will notice python has created files and folders automaticly
    • .\scripts\activate
    • Console Result: (django-project) c:\py\django-project
From here, all my Python commands will only affect the Django-project file, meaning I will need to install Django and start a project.
  • pip install django
  • django-admin startproject family-board
  • python will install django and add folders and files into my enviroment i will notice the root folder appear named family-board
  • cd family-board
In my family-board folder, I will see a file called manage.py and a subfolder called family-board. Inside the family-board subfolder are more .py files to manage settings, URLs, etc.

Takeaways - easy-to-use virtual environments for projects make it easy to keep project-specific packages and settings enclosed without cross contaminating other projects. They also allow you to test out new versions of packages before deployment.