Form in Django plays a key part in other components. It glues the data from the web form to the database or other services. It serves as the bridge between user input and the database or other services. A Django Form takes user input from web forms, transforms it into Python objects, prepares the data for storage, and saves it to the database. Conversely, forms can retrieve data from the database or other services, converting Python objects back into HTML/HTTP for user interaction. Additionally, Django Forms provide essential validation and error-handling mechanisms to ensure data integrity.

Forms are also responsible …

This is an introduction to the Django Template system. Templates are primarily used for clients who expect the HTTP response to be rendered in web browsers. Consequently, the format of the response is typically in HTML, which can link to various media assets such as JavaScript files, CSS stylesheets, images, and more.

Think of a template as a combination of HTML and its domain-specific language, which includes template tags and filters. Django template syntax is the superset of HTML and it adds dynamic content rendering, making it easy to inject Python objects (the context dictionary/key-value pairs) into HTML. The basic …

This article is about Django's View and URL components. When an HTTP request is ingested by CGI, WSGI (Web Server Gateway Interface), Django's URL pattern matcher routes the request to a designated view. The role of a view is to process the request and generate an appropriate response.

The role of View process the request into a response. In the process, View interacts with Model and Template typically. A view function takes a Python request object, which is parsed from the raw HTTP bytes received from WSGI. It facilitates access to data from databases, media assets, or other services, and …

In web development, databases (also memory cache) are critical in managing data efficiently since their operations are implemented in well-considered data structures and algorithms (and other reasons).

Managing databases is a complex task. Django simplifies it through the Object Relational Mapping ORM system. We don’t explicitly define SQL schemas for relational databases such as SQLite, PostgreSQL, or MySQL. Instead, the SQL schema is auto-generated by reading the model classes defined in models.py. This feature allows developers to focus more on coding in Python rather than managing SQL directly for most common works.

ORM

ORM is a common technique found in …

This article is about the backbones of a general Django project: Model-View-Template, Form, and Settings, including the interplay of the components concisely without going into details of each. Form and Settings are virtually as essential as MVT.

Scaffolding

First of all, starting a Django project by:

django-admin startproject ${project_name}
cd ${project_name}/
python manage.py startapp <app>
python manage.py startapp <app2>

It generates a project with a similar structure:

+<BASE_DIR> (project_name)
|
+---- manage.py
|
+---+-<PROJECT_DIR_project_name>
|--- __init__.py
|--- wsgi.py, asgi.py
|--- settings.py, urls.py
|
+---+-<app_name>
|--- __init__.py
|--- models.py, urls.py, views.py, admin.py, templates/, static/
|
+---+-<app2_name> …

A combination of Vim and command-line tools is a handy text-processing toolkit for many tasks. This entry provides some examples. It makes coding and writing convenient and enjoyable.

Linux text tools

The magic of | allows the output of a function to be the input of another. This is analogy to one of cores of functional programming: with different combination of functions, one can achieve different results easily without rewriting the partial codes.

Some list of linux or python text tools are natually integrated with Vim:

  • awk: a powerful pattern scanning and processing language
  • column: columnate lists
    • (print …

Vim is a fundamental application in Linux. Oiled editing significantly aids in handling various Linux applications. Consider Vim as a means to elevate mastery of Linux. This configurable, open-source tool, driven by community contributions, offers numerous packages(plugins/add-ons) and features its own scripting language. It is like a Minecraft sandbox that allows one to create mind tools to process texts.

This article covers some essentials for customizing the vimming experience, including vim/neovim versions and some common logic in the Vim manual.

Vim/Neovim loads a bundle of built-in packages at the start. One of the builtin packages is ftplugin. It …

What’s the fuss about? One can simply hover and click the mouse to navigate anywhere: among characters, words, lines, split tabs, files, or even hosts. Yes, if the mouse is available.

Mouse is indeed an important HID, and I rely on it in daily use cases.

Most coding experiences are similar to playing first-person shooter games, as they both require quick, precise mouse movements and rapid keyboard typing while scanning the screen. However, working on remote servers without an X-Windows (or Windows) system can be frustrating. This awkwardness can arise on a bare-metal cloud machine or small embedded devices.

It …

I hoped someone had emphasized the importance of :help to me. The Vim Help manual may not be hard to discover. One may just press "F1" to open it up. However, the flood of information made it hard to realize that a dictionary-like document is the most valuable user guide.

Many experiences reading manuals (including the electric appliances) showed that words and language styles are unique. Maybe it is the most concise, least ambiguous way of discussing the product among users. That is the reference users would agree to use the terms to refer to something.

I still learn a …

This is a continuation to What I didn't know about Immutability (I)

Previously, the terminology and the main differences between the immutable and the mutable were discussed.

In this part, the discussion goes on extended context related to immutability.

Comparison

Let's keep this table as a reference for ongoing discussion.

┌────────┬─────────┬─────────┬──────────┬───────────┬─────────┬─────────┬─────────┐
│Language│Data Type│prim/ref?│Immutable?│Comparable?│Sortable?│Hashable?│Iterable?│
├────────┼─────────┼─────────┼──────────┼───────────┼─────────┼─────────┼─────────┤
│Java    │int      │primitive│    ✓     │   value   │    ✓    │    ✓    │    x    │
├────────┼─────────┼─────────┼──────────┼───────────┼─────────┼─────────┼─────────┤
│Java    │double   │primitive│    ✓     │   value   │    ✓    │         │    x    │
├────────┼─────────┼─────────┼──────────┼───────────┼─────────┼─────────┼─────────┤
│Java    │String   │reference│    ✓     │   value   │    ✓    │    ✓    │         │
├────────┼─────────┼─────────┼──────────┼───────────┼─────────┼─────────┼─────────┤
│Java    │Class    │reference│    x     │ mem …