DEV Community

Vernum mokua for Swahilipot Developers

Posted on

Technical Progress Report: Python, Django, and Project Development

Overview
In the past two weeks, significant progress was made in installing Python and Django, as well as in creating and developing a Django project. This report details the steps taken to set up the environment, create a project and application, and interact with various components of the Django framework.

Environment Setup
Python Installation:

Python was installed on the system to facilitate Django development. This involved downloading the latest version from the official Python website and configuring the environment variables to ensure Python was accessible from the command line.

Django Installation:

Django was installed via pip, the Python package installer. The command used was pip install django, which downloaded and installed the Django framework and its dependencies.
Django Project Creation

Project Initialization:

A new Django project named my_site was created using the command django-admin startproject my_site. This generated a directory structure for the project, including essential files such as settings.py, urls.py, and manage.py.

Application Creation:

Within the my_site project, an application named pols was created using the command python manage.py startapp pols. This created a directory for the app with its own set of files, including models.py, views.py, forms.py, and urls.py.
Backend Interaction

Views:

Views were implemented in pols/views.py to handle HTTP requests and return HTTP responses. These views are responsible for processing user input, interacting with the database, and rendering templates.

Forms:

Forms were defined in pols/forms.py to manage user input and validation. Django’s form handling capabilities were utilized to create and validate forms, ensuring proper data management and user interaction.

URLs:

URL routing was configured in pols/urls.py to map URLs to specific views. This involved defining URL patterns and linking them to the corresponding view functions.

Settings:

The settings.py file within the my_site project was configured to include the pols app in the INSTALLED_APPS list, ensuring that Django recognizes the application and its components.

Models:

Models were defined in pols/models.py to represent the database schema. This involved creating classes that inherit from django.db.models.Model, defining fields, and specifying relationships between models.

Database Interaction:

Django’s ORM was used to interact with the database. This included running migrations to create database tables based on the models defined in pols/models.py. The commands python manage.py makemigrations and python manage.py migrate were executed to apply changes to the database schema.

Top comments (0)