Loading lesson path
Django
Django Tutorial focused on Django Introduction and related concepts.
Django Tutorial
Django Introduction
To install Django, you must have Python installed, and a package manager like PIP. PIP is included in Python from version 3.4. Django Requires Python To check if your system has Python installed, run…
Django - Create Virtual Environment
Install Django
Django Create Project
Django Create App
Views Django views are Python functions that take http requests and return http response, like HTML documents. A web page that uses Django is full of views with different tasks and missions. Views ar…
URLs Create a file named urls.py in the same folder as the views.py file, and type this code in it: my_tennis_club/members/urls.py from django.urls import path from . import views urlpatterns = [ pat…
Templates In the Django Intro page, we learned that the result should be in HTML, and it should be created in a template, so let's do that. Create a templates folder inside the members folder, and cr…
Django Models
Add Records The Members table created in the previous chapter is empty. We will use the Python interpreter (Python shell) to add some members to it. To open a Python shell, type this command: python…
Update Records To update records that are already in the database, we first have to get the record we want to update: >>> from members.models import Member >>> x = Member.objects.all()[4] x will now…
Delete Records To delete a record in a table, start by getting the record you want to delete: >>> from members.models import Member >>> x = Member.objects.all()[5] x will now represent the member at…
Add Fields in the Model To add a field to a table after it is created, open the models.py file, and make your changes: my_tennis_club/members/models.py from django.db import models class Member(model…