Tag:django

  • On the cache of Django page cache_ How are keys generated

    Time:2021-10-1

    Page cache e.g. ? 1 2 3 @cache_page(time_out, key_prefix=key_prefix) def my_view():  … By default, the default cache in the configuration is used cache_ The page decorator is converted from the caching middleware cachemiddleware Cachemiddleware inherits updatecachemiddleware and fetchfromcachemiddleware Updatecachemiddleware inherits from middlewaremixin and only rewrites process_ The response method is used to cache the view […]

  • Implementation of returning data using Django’s jsonresponse

    Time:2021-9-20

    urls.py from django.conf.urls import url from . import views   urlpatterns = [ url(r’^show/’, views.show_view, name=’show’) ] Create show in views.py_ View function from django.http import HttpResponse from django.shortcuts import render from .models import * from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage from django.http import JsonResponse def show_view(request): #Gets the current number of page numbers num […]

  • Use of shell commands in Django

    Time:2021-7-30

    Shell tools Django’s manage tool provides shell commands to help us configure the running environment of the current project (such as connecting to the database), so that we can directly execute test Python statements in the terminal. Enter the shell with the following command python manage.py shell Import two model classes for later use from […]

  • Simple understanding of Django ORM common field types and parameter configuration

    Time:2021-6-28

    This article mainly introduces a simple understanding of Django ORM common field types and parameter configuration, this article through the example code is very detailed, for everyone’s study or work has a certain reference learning value, need friends can refer to 1、 Numerical type Autofield corresponds to int (11). Self increasing primary key, provided by […]

  • Analysis of Django password storage strategy

    Time:2021-4-25

    1、 Source code analysis The 1.4 release of Django includes some important security improvements. One is to use pbkdf2 encryption algorithm instead of SHA1. Another feature is that you can add your own password encryption method. Django will use the first password encryption method you provide (in your   setting.py   There should be at […]

  • Implementation of batch data insertion in Django

    Time:2021-2-25

    Project requirements: access a URL of Django back end in browser (for example: 127.0.0.1:8080 / get)_ Generate 1000 pieces of data in the database in real time, query the generated data and display it to the front page views.py from django.shortcuts import render, HttpResponse, redirect from app01 import models def get_book(request):   #For loop inserts 1000 […]

  • Implementation of docker deployment of Django + MySQL + redis + gunicorn + nginx

    Time:2021-1-19

    1、 Preface Docker technology is very popular now. It is very efficient to build a project environment through containers. So recently, I took the time to read some tutorials, and then changed the blog deployment mode to docker. I don’t feel that there is any particularly good blog on the InternetdockerdeploydjangoProject tutorial, specially wrote this […]

  • Implementation of automatic data verification for Django’s form component

    Time:2021-1-8

    1、 Form introduction When we used the form table to submit data to the one-way back end in the HTML page before, we would write some tags to get the user’s input and wrap them with the form tag. At the same time, we need to verify the user’s input in many scenarios, such as […]

  • Django2. * + mysql5.7 development environment integration tutorial diagram

    Time:2020-12-4

    Environmental Science: MAC_OS 10.12 python 3.6 mysql 5.7.25 django 2.2.3 Premise: Python Django MySQL has been successfully installed and can be run independently 1、 Database configuration in settings DATABASES = { ‘default’: { ‘ENGINE’: ‘django.db.backends.mysql’, “USER”: “user name”, “PASSWORD”: “your password”, “NAME”: “db name” } } 2、 Replace default database driver 1. Install pymysql pip3 […]

  • The teaching of using graphics and text in Django background management system

    Time:2020-6-3

    Checking the configuration file of Django background management system Check root urls.py file Start the project, enter IP port / admin in the browser, for example: 127.0.0.1/8000/admin enter Registration background management system super management 1. Create ා create a normal user with clear password (not recommended)2.create_ User ා create a normal user, password ciphertext (recommended)3. […]

  • How to use local CSS / JS file through Django

    Time:2020-5-31

    This article mainly introduces how to use the local CSS / JS file through Django. The example code in this article is very detailed, which has a certain reference learning value for everyone’s study or work. You can refer to the following for friends who need it I read a lot of articles on how […]

  • Django blog development tutorial 9 – support for markdown syntax and code highlighting

    Time:2020-4-3

    In order to make blog posts have a good layout and display more rich formats, we use markdown syntax to write our blog posts. Markdown is an HTML text markup language. As long as we follow its agreed syntax format, markdown’s renderer can convert our articles into standard HTML documents, so that our articles can […]