URL name

1. DB

DB initialization

  1. Delete db.sqlite3

  2. Delete migration files

Check migration files

python manage.py showmigrations

Create migrations again

python manage.py makemigrations

Output corresponding SQL statement

$ python manage.py sqlmigrate articles 0001
       [app_label] [migration_name]
BEGIN;
--
-- Create model Article
--
CREATE TABLE "articles_article" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "title" varchar(140) NOT NULL, "content" text NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL);
COMMIT;

Run migrate

create()

For creation, you can also do it as follows!

IntegrityError

: This exception is raised when the relational integrity of the data is affected.

2. GET & POST method

  • GET

    • Retrieve data

    • Display of specific resources

    • <a> tag, <form> tag and requests sent from browser address bar, etc.

    • Data is transmitted using URL (querystring)

      • Has size limitations & security issues

  • POST

    • Post data

    • Submit to specific resources (server state change)

    • Usually sent to server through HTML Form, creating server changes

    • Data is transmitted in the body of HTTP request message

HTTP (Hyper Text Transfer Protocol)

  • Protocol that allows resources to be fetched

  • Foundation of all exchanges on the web

Request

HTTP Request
  • URL (Uniform Resource Locators)

    • Address of unique resource defined on the web

  • protocol :// domain: port/ path/?parameters#anchor

Response

HTTP Response

views.py modification

Adding CSRF token

You can see that csrf token is added as a hidden value

CSRF Token

Send simple request with Curl

Using Telnet

Installation

Send request

3. Specifying app_name

urls.py

views.py

In html

4. get_object_or_404

article = Article.objects.get(id=pk)

  • get() raises error if value doesn't exist

    • Method that returns only one

  • So what we use is

5. Static files

settings.py

+

Traceroute

TraceRoute - Linux / TRACERT - Windows

A command that tracks the path information to reach a specified host and the delay time at each path, simply think of it as a path tracking tool (uses ICMP!)

  • A network command that tracks path information to reach a specified host and delay time at each path, useful for finding out where bottlenecks occur when a specific site is not accessible or has delays.

  • By checking each path that gets connected, you can confirm which path (Routing) is used for connection, how much speed delay exists in which section, and where packets stopped

  • However, values may vary due to many influences such as time zone/internal traffic/server status, so repeated confirmation is necessary!

Install traceroute

Use traceroute

MVC Pattern

  • model driven design

  • data modeling

Last updated