Flask login exercise

Login based on blueprint CBV mode Use blueprint and cbv mode to complete login function Jump to the home page after login Save the session in the redis database on liunx Verify whether it is the login user by using "before" request blueprint from flask import Blueprint,render_template,redirect,views,request,session user = B ...

Posted by Petty_Crim on Sat, 26 Oct 2019 12:00:19 -0700

Python Django implements simple registration function

  For project creation strategy, please refer to the introduction of previous documents. The directory structure is as follows   Edit views.py from django.shortcuts import render # Create your views here. from django.http import HttpResponse from django.shortcuts import render from common.DBHandle import DataBaseHandle import ...

Posted by ixalmida on Wed, 23 Oct 2019 14:32:39 -0700

Python Decorators

http://book.pythontips.com/en/latest/decorators.html In the two notes of build in functions (3.6) and python context manager, there are preliminary examples of decorators. This article combines a blog of Colgate University's bull people to systematically explain the role of decorators in Python. First, put forward a unified concept Decorator ...

Posted by PeeJay on Wed, 23 Oct 2019 00:48:49 -0700

Django writes data model classes

The design of database and table structure is the basis of website. In Django, you don't need to deal with the database directly through SQL statements, but you can create the data model completely with Python classes, and then give Django to complete the operation of creating the database. Data model class The data model class needs to be w ...

Posted by lJesterl on Sun, 20 Oct 2019 08:10:53 -0700

Authentication mechanism of Django template (csrf_token)

csrf authentication mechanism: In django, for POST request, csrf will conduct authentication processing. csrf authentication mechanism is to prevent cross site forgery. Without any processing, POST request will report an error.   csrf authentication -- template operation: Actions in template file: In django project, the POST request ...

Posted by ccravens on Sat, 19 Oct 2019 13:41:03 -0700

Python - Django - Tags for Template Language

Label use {%} Annotation statement: {#} for loop: views.py: from django.shortcuts import render, redirect, HttpResponse from app01 import models # Filter test def filter_test(request): hobby = ["Reading", "Basketball", "Movie", "Music"] return render(request, "filter_test.html", {"hobby_list": hobby,}) filter_test.h ...

Posted by wxflint on Mon, 14 Oct 2019 09:22:07 -0700

django uploads images for simple verification and automatic modification of image names

Links to the original text: https://www.jianshu.com/writer#/notebooks/28758830/notes/51826042/preview django implements automatic name modification after uploading files (pictures) and various reminders when uploading pictures on pages: 1. F ...

Posted by tom_b on Fri, 11 Oct 2019 07:37:09 -0700

Django lazy loading and LazyObject

Looking at the login middleware, I found that request.user returned a SimpleOject object. Looking down, I turned to LazyObject. I didn't understand the source code for half a day. After searching a lot of information on the Internet to find out what functions lazy loading implements, and then looking back at the source code, we may know the pr ...

Posted by Gwayn on Thu, 10 Oct 2019 15:35:49 -0700

Django Component-Middleware

Django request execution flow chart:   middleware The Concept of Middleware Middleware, as its name implies, is a process between request and response processing, which is relatively lightweight and changes the input and output of django globally. Because the change is global, it needs to be used cautiously, and poor performance will be a ...

Posted by Rabea on Wed, 09 Oct 2019 20:39:21 -0700

Django-Docker Containerized Deployment: Django-Docker-MySQL Deployment

In the previous chapter, we successfully built a containerized Django project, using the default Sqlite database. Sqlite is easy to use, but online deployment often chooses more efficient and reliable databases, such as MySQL. Based on the previous chapter, this chapter will modify and build the container project of Docker + Django + MySQL. Doc ...

Posted by blckspder on Wed, 09 Oct 2019 18:04:02 -0700