django's routing layer

Catalog How to establish orm table relationship One-on-one One to many Many to many django request lifecycle flowchart url.py routing layer Route matching django matching routing law Cancel the function of django to automatically slash the browser Restrict th ...

Posted by ganeshcp on Mon, 25 Nov 2019 11:31:01 -0800

Django-40-ORM many to many new

Premise (initial table data) The book table and the author table are many to many relationships. A book may have multiple authors, and an author may have multiple books add(* []): can be number (i.e. id); object; object list book table author table Book & authors table (relational table) Django ABCD study.app01. ...

Posted by samba_bal on Mon, 25 Nov 2019 09:03:07 -0800

Django-42-ORM many to many query (ManyToManyField created automatically)

Premise (initial table data) The difference between manual creation and automatic creation is that there is no third operable table in the automatically created table, and there is no difference in other tables. This article only takes automatic creation as an example book table author table Book & authors table (re ...

Posted by Adthegreat on Mon, 25 Nov 2019 08:37:10 -0800

3. Write the first django application (voting application), the third part is a brief process

Part III official website reference link https://docs.djangoproject.com/zh-hans/2.2/intro/tutorial03/1. Write more views:Add functionpolls/views.py def detail(request, question_id): return HttpResponse("You're looking at question %s." % question_id) def results(request, question_id): response = "You're looking at the results of questi ...

Posted by jo.nova on Sun, 24 Nov 2019 13:45:58 -0800

From getting started to mastering the custom Response of the Flask framework

Knowledge points: 1. User defined response information 2. Return to Json I. General Situation We all know that when a browser makes a request, the server will give a response. This response includes the returned content type, status code, server version, etc. The following picture: If we don't modify the response information ...

Posted by qadeer_ahmad on Sun, 24 Nov 2019 13:35:54 -0800

Before request and after request in Flask

Catalog 1. Premise, disadvantages of decorator 2. Before & after request 2.1 before Ou request analysis: 2.2 after request analysis: 3. Before you request application 4. Before you request application 5. Implement a simple page login with flash If one day the b ...

Posted by yarub on Fri, 22 Nov 2019 04:43:50 -0800

python: front end (HTML) + back end (Django) + database (MySQL)

1. Create an html file for a simple web page registration demo <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>register</title> </head> <body><!--Form field action Used to submit acquired to background address--> <form action="save" method="get"> ...

Posted by curtis_b on Thu, 21 Nov 2019 07:45:04 -0800

django sets cookie s and session s

1 set cookie s In this case, the application name is cookie Model model from django.db import models from django.db import models class UserInfo(models.Model): username = models.CharField(max_length=64) password = models.CharField(max_length=64) Database migration python manage.py makemigrations python manage.py migrate ...

Posted by BlueGemini on Tue, 19 Nov 2019 08:19:28 -0800

Django framework 5-cookie s and session s

Why do we have cookie s and session s? Browser sends http request to server, establishes session, server returns complete, session ends, browser and service disconnect Send the http request again and establish the session again. The user information will be lost. The server cannot distinguish the requested information. A login account. After t ...

Posted by NINTHTJ on Tue, 19 Nov 2019 07:26:37 -0800

How to Separate Media, Static Files and Web Pages in django

In the django project, static files, media files and html code account for a large part, so how can we separate them so that we and the server can manage and use them easily? static fileStatic, as the name implies, is a static file, and django comes with a command to extract all the static files in the projectpython3 manage.py collectstatic I'm ...

Posted by xylex on Mon, 11 Nov 2019 00:28:40 -0800