Method of calling object attribute or object in html template of django template
Environment: relying on the original test2 database
python3 version
Multi python environment
Enter, python 3 virtual environment, new project test4:
]# cd py3/django-test1/
]# django-admin startproject test4
To create an app bookshop:
]# cd test4
]# python manage.py startapp bookshop
Modify the settings.py main configuration file:
]# vim test ...
Posted by bloodgoat on Sat, 07 Dec 2019 03:25:16 -0800
Django 2.1.3 middleware use
Environmental Science
Win10
Python3.6.6
Django2.1.3
Middleware role
Middleware is used to globally modify the input or output of Django.
Common uses of Middleware
cache
Session authentication
Log record
abnormal
Middleware execution process
image
Global exception capture implementation
Create django project & add app ...
Posted by piet123 on Thu, 05 Dec 2019 11:03:17 -0800
Upload files by python requests
Reference resources
django upload file
Temporary file, name can be obtained
Memory file
demand
django receives the file uploaded by the front end and forwards it to wechat server
requsts upload file
https://2.python-requests.org//zh_CN/latest/user/advanced.html#streaming-uploads
Streaming upload
with open('massive-body') as f:
requests.post ...
Posted by Daisatske on Thu, 05 Dec 2019 07:14:36 -0800
Resolve Python 3.6.5+Django 2.0 integration xadmin background click Add or Content details report list index out of range error
Problem DescriptionWhen creating a Model, if a field of type DateTimeField exists, the list index out of range is reported when adding to the Model in the xadmin back-end management interface.
This is the Model created in the last article:
class IDC(models.Model):
name = models.CharField(max_length=64)
contact = models.CharField(max_length=32) ...
Posted by Malkavbug on Tue, 03 Dec 2019 03:51:33 -0800
Change the default database to mysql in Django
In Django, sqlite3 database is used by default. Today, I studied how to change it into a common mysql database.
Because the project uses python3, and MySQL DB does not support the version of python3, if you use the version of python3.x, PIP install MySQL DB will report an error.
Later, through Google, it was found that pymysql could be used i ...
Posted by sujata_ghosh on Mon, 02 Dec 2019 23:51:06 -0800
html template escape of django
The environment is the same as the django article.
Start django's web Service:
]# cd py3/django-test1/test4
]# python manage.py runserver 192.168.255.70:8000
In an html template, if the content you want to display contains html Tags:
Edit view:
]# vim bookshop/views.py
from django.shortcuts import render
from .models import *
...
def htmlTes ...
Posted by katarra on Mon, 02 Dec 2019 19:20:52 -0800
bootstrap fileinput control + django background upload, echo simple use
1. Control Download: https://github.com/kartik-v/bootstrap-fileinput/
Official website: http://plugins.krajee.com/file-input
Files to be imported: 1. jquery.js
2,bootstrap.js bootstrap.css
3. The font awesome.css control icon uses font awesome, so it needs to be imported
4,finleinput.js fileinput.cs ...
Posted by amjohnno on Mon, 02 Dec 2019 12:22:35 -0800
Direction resolution of django template: generate link address based on url
Environment the same django article.
web services running django:
cd py3/django-test1/test4
python manage.py runserver 192.168.255.70:8000
First, use a tag hyperlink in html to automatically match the url route of the application, and then display the specified html page:
Edit view function:
vim bookshop/views.py
from django.shortcuts imp ...
Posted by Hoppus on Mon, 02 Dec 2019 08:15:47 -0800
One click site building guide of native Tencent cloud centos7.5 Django Nginx+uwsgi
First, you need to have a server and domain
Preprocessing
Install GCC, ZLIB, PCRE, OPENSSL...
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
Pyhton's upgrade and iteration
Native linux generally only provides Python 2.7, so the first step is to upgrade Python and use the latest and stable version. (it i ...
Posted by EchoFool on Sun, 01 Dec 2019 07:34:10 -0800
django general authority control framework
In the web project, according to different users, they will definitely limit their different permissions. Using the following modules, almost all the daily permissions can be controlled
Permission ﹐ hook.py ﹐ custom permission control, must return True/false, True for permission, false for rejection
Permission? List.py? Control user permissio ...
Posted by resago on Sat, 30 Nov 2019 06:24:19 -0800