HTML Forms with django

HTML Forms are a key technology to know

Django makes building the html code around Forms much easier. 

Installing Python,  Django, Pycharm and DB Browser


Since Django is python based you need to install Python. It’s best to install Python 3. The instructions are here for Windows, Linux/Unix or Mac OSX.
“https://www.python.org/downloads/
Install Python 3.9 or better
Check that Python is up and running version 3 $ python -V Python 3.x.y

To install Django use these instructions
“https://www.djangoproject.com/download/”

Check that Django is running by starting a shell
$ python3 -m django shell
Python 3.8.5 (default, Jan 27 2021, 15:41:15)
[GCC 9.3.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
(InteractiveConsole)
>>>
Use quit() or Ctrl-D (i.e. EOF) to exit

>>>
now exiting Interactive Console…
$

Install Pycharm for your operating system
https://www.jetbrains.com/help/pycharm/installation-guide.html
I will use pycharm later to visualize the Python code in Django.

Install DB Browser for SQLite
https://sqlitebrowser.org/dl/ has instructions for various OSes
For most Linuxes its
# snap install sqlitebrowser

Create a test folder/directory called djangoTest and cd into it.
Next Run 
$ django-admin startproject mysite
this creates a folder called mysite which is the base code for a new website.
cd to mysite to see a manage.py file.

Start the Server

$ python3 manage.py runserver
Watching for file changes with StatReloader
Performing system checks…

System check identified no issues (0 silenced).

You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run ‘python manage.py migrate’ to apply them.
May 16, 2021 – 03:00:47
Django version 3.2.2, using settings ‘mysite.settings’
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
^Callen@allenComputer:~/djangoTest/mysite$ python3 manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial… OK
Applying auth.0001_initial… OK
Applying admin.0001_initial… OK
Applying admin.0002_logentry_remove_auto_add… OK
Applying admin.0003_logentry_add_action_flag_choices… OK
Applying contenttypes.0002_remove_content_type_name… OK
Applying auth.0002_alter_permission_name_max_length… OK
Applying auth.0003_alter_user_email_max_length… OK
Applying auth.0004_alter_user_username_opts… OK
Applying auth.0005_alter_user_last_login_null… OK
Applying auth.0006_require_contenttypes_0002… OK
Applying auth.0007_alter_validators_add_error_messages… OK
Applying auth.0008_alter_user_username_max_length… OK
Applying auth.0009_alter_user_last_name_max_length… OK
Applying auth.0010_alter_group_name_max_length… OK
Applying auth.0011_update_proxy_permissions… OK
Applying auth.0012_alter_user_first_name_max_length… OK
Applying sessions.0001_initial… OK
allen@allenComputer:~/djangoTest/mysite$ python3 manage.py runserver
Watching for file changes with StatReloader
Performing system checks…

System check identified no issues (0 silenced).
May 16, 2021 – 03:01:22
Django version 3.2.2, using settings ‘mysite.settings’
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

After clearing the errors, I restarted the Server, opened the browser to 
localhost port 8000

Creating the Blog 

Creating a blog requires HTML forms, the database and a definition of the model. HTML design should follow the MVC principles. To violate the principles leads to problems. MVC stands for Model, View and Control. It’s commonly called the separation of concerns. Model stands for data, View is what the user sees. Control integrates getting model data and applying HTML to create what the website displays. 

The python code that created the schema or the entry into SQLite database

Entering the first post 

The post as seen in the database

“https://djangocentral.com/building-a-blog-application-with-django/”

“https://www.youtube.com/watch?v=CnaB4Nb0-R8&list=PLCC34OHNcOtr025c1kHSPrnP18YPB-NFi&index=3”

“getbootstrap.com”

<i class="bi bi-arrow-down-left-circle-fill"></i>