Skip to content

sunnyau/python_learning_log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python_learning_log

This project follows the Python Crash Course book, chapter 18. Getting Started with Django

book

Setting Up a Project

Creating a Virtual Environment

learning_log$ python -m venv ll_env

Activating the Virtual Environment

learning_log$ source ll_env/bin/activate (ll_env)learning_log

(Optional) Deactivate the Virtual Environment

(ll_env)learning_log$ deactivate

Installing Django

pip install django

Installing collected packages: sqlparse, asgiref, django Successfully installed asgiref-3.8.1 django-5.0.7 sqlparse-0.5.0

Creating a Project in Django

(ll_env)learning_log$ django-admin startproject learning_log .

Creating the Database

(ll_env)learning_log$ python manage.py migrate

Viewing the Project

python manage.py runserver

Watching for file changes with StatReloader Performing system checks...

System check identified no issues (0 silenced). July 15, 2024 - 05:58:56 Django version 5.0.7, using settings 'learning_log.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.

[15/Jul/2024 05:59:01] "GET / HTTP/1.1" 200 10629 Not Found: /favicon.ico [15/Jul/2024 05:59:01] "GET /favicon.ico HTTP/1.1" 404 2116

Open development server

http://127.0.0.1:8000/

Screenshot (15)

The command startapp appname tells Django to create the infrastructure needed to build an app.

(ll_env)learning_log$ python manage.py startapp learning_logs

update settings.py INSTALLED_APPS

NSTALLED_APPS = [ 'learning_logs', ... ]

Here we start a section called My apps, which includes only learning_logs for now.

python manage.py makemigrations learning_logs

python manage.py migrate

The Django Admin Site

create superuser in Django

python manage.py createsuperuser

ll_admin

password :

Registering a Model with the Admin Site

update admin.py file

access to admin page

http://127.0.0.1:8000/admin

Screenshot (16)

Screenshot (17)

TO BE CONTINUED ON PAGE 389

About

Python Crash Course book. Chapter 18. Getting Started with Django

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published