Rest framework learning quick start
This article mainly refers to the Rest Framework official website documents: https://www.django-rest-framework.org/
And then I realize my own personal summary.
Development tools: Pycharm, python 3.7, Django 2.1, djangorest framework-3.9.4
Contents of this article
New project:
Serializer:
View:
urls.py:
Configur ...
Posted by McMaster on Sat, 02 Nov 2019 04:27:30 +0100
Simple use of its dangerous
Why use itsdangerous is to ensure that your encrypted data has not been modified, because the original data cannot be re solved after modification, and the content cannot be solved after timeout. Activate the application scenario and send an activated website to you. If you fail to activate within a cer ...
Posted by very_new_user on Sat, 26 Oct 2019 19:02:28 +0200
Many to many
Create the third table to establish many to many relationship
Table creation
# The teacher table and student table can be a many to many relationship. When creating a table, you can manually create a third table to establish an association.
class Student(models.Model):
name = models.CharField(max_length=32, null=True)
age = mod ...
Posted by WiseGuy on Tue, 22 Oct 2019 18:22:48 +0200
Django JsonResponse does not automatically set cookie s
[background]
At present, we are doing a web project with front-end and back-end separation. The back-end uses django framework, and all API s only return json. In this process, we encounter a problem that all json response django will not actively set the cookies of response object, which further makes the cookie value of csrftoken never appea ...
Posted by ankur0101 on Tue, 22 Oct 2019 17:21:54 +0200
Django uses haystack+whoosh to realize search function
In order to achieve the search function in the project, we use the full-text search framework haystack+ search engine whoosh+ Chinese word packet jieba
install and configure
Installation of required packages
pip install django-haystack
pip install whoosh
pip install jieba
Register haystack application to settings file
INSTALLED_APP ...
Posted by tamayo on Tue, 08 Oct 2019 22:48:53 +0200
Cookie and Session of Django
Cookie
Get Cookie
request.COOKIES['key']
request.get_signed_cookie('key', default=RAISE_ERROR, salt='', max_age=None)
The parameters of get_signed_cookie method:
default: default value
Salt: Encrypted salt
max_age: Background control expiration time
Set Cookie
rep = HttpResponse(...)
rep = render(request, ...)
rep.set_cookie(key,value,...) ...
Posted by johanlundin88 on Mon, 07 Oct 2019 12:53:36 +0200
Python script for generating Chinese graphic verification code
Links to the original text: https://www.cnblogs.com/whu-zeng/p/4855480.html
Note: this script is not original, just a little adjustment based on the original author's code. Original links: https://www.cnblogs.com/whu-zeng/p/4855480.html
Many ...
Posted by ligraci on Sat, 05 Oct 2019 13:25:36 +0200
python's Django framework (use of APP and ORM)
12.3 APP
12.31 Create APP
A Django project can be divided into many APP s to isolate code from different functional modules.
Create an APP from the command line:
python3 manage.py startapp app01
Create an APP, remember to tell Django the name of the app, add in settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'djan ...
Posted by CBaZ on Sat, 05 Oct 2019 10:10:56 +0200
The Use of form in Python
Article directory
The main role of form is:
1. Create some data types in the model
2. Create new forms.py in model.py directory
3. Form validation in view view
4. On the html page, the code is very simple, which django does well.
The main role of form is:
1. Form framework generation in html, ...
Posted by kkobashi on Thu, 03 Oct 2019 00:48:13 +0200
Construction of python django+bootstrap4+mysql intelligent transportation system
Before, I did a training project, but I haven't shown how to do it. Now let me explain how to use Django + bootstrap 4 + mysql to implement this intelligent transportation system. The bootstrap 4 framework and mysql database are used here.
First: Contents of Software Projects
1. Brief introduction of training projects
Intelligent Transpor ...
Posted by 14zero on Mon, 30 Sep 2019 22:00:46 +0200