This article mainly introduces some features of HackerNews in the Python Django framework, including voting "top" comment and other features. For more information, see
Step-by-step instructions
This is the video text version provided to those who prefer reading. We will create a social news website similar to Hacker News or Reddit. It will be called "steel rumors" as a place to share interesting stories ab
(APP)
Creating databases and Configuration databases
Configuring templates and Static file correlation
Comment out the CSRF line in settings.py
6. Django Template language (rules for string substitution)1. {{variable}} {{variable.}}2. For loop{% for I in xx%}{{i}}{% ENDFOR%}Forloop.counter---count3. If judgment{% if condition%}Things to do when conditions are established{% Else%}Conditions are not set up to do the thing{% ENDIF%}Spec
session_cookie_secure = False # whether HTTPS transport cookie session_cookie_httponly = True # Whether the SESSION's COOKIE only supports HTTP transport session_cookie_age = 1209600 # Session cookie Expiration Date (2 weeks) session_expire_at_browser_close = False # whether to close the browser so that the session expires Session_save_ Every_request = False
This article describes how to use the Manager method in the Python Django framework, including modifying the initial ManagerQuerySets and adding additional Manager methods. For more information, see the statement Book. objects. in all (), objects is a special attribute and needs to be used to query the database. In chapter 2, we simply say that this is the module manager. Now it is time to learn more about
This article describes how to use the compression component DjangoCompressor in the Python Django framework. This tool is mainly used to compress jscss. For more information about how to speed up website loading, we usually need to compress JavaScript code and css code. It is time-consuming and labor-consuming to manually compress these js and css files.
Django
Django is an open source Web application framework written by Python. The software design pattern of MVC is adopted, namely model M, view V and Controller C. It was originally developed to manage some of the news content-oriented Web sites owned by the Lawrence Publishing Group, which is CMS (Content management system) software. and was released under the BSD license in July 2005. The
The simplest performance of the Django, flask, bottle, Tornado framework itself is measured. The performance of Django is completely silent.
Django, flask, bottle all use Gunicorn+gevent to start, single process, and turn debug off, and the request returns only one string OK.
Tornado start directly, other content is c
For details about how to use forms in the Django framework of Python, djangoforms
Form Functions
Automatically generate HTML form elements
Check the validity of form data
If a verification error occurs, re-display the form (data is not reset)
Data type conversion (convert data of character type to corresponding Python type)
Form-related objects include
Widget: a tool used to render HTML element
. Create an application in the MySite directory HelloWorldPython manage.py Startapp HelloWorld then we can see one more HelloWorld folder under Mysites3. Modify the views.py file under HelloWorld#-*-Coding:utf-8-*-From __future__ import unicode_literalsFrom django.shortcuts Import RenderFrom django.shortcuts import HttpResponse# Create your views here.def index (Request):#request. Post#request. GETReturn HttpResponse ("Hello world!")4. Modify the urls.py file under MysitesFrom Django.conf.urls i
,month='3'): return HttpResponse ('%s-%s'% (year,month))ViewTwo URLs all point to the same view, and if the first pattern matches, the view function will use the default value of the parameter, and if the second pattern matches, the view function will use the value captured by the regular expressionincluding other Urlconfs from Import URL from Import Admin from Import = [ url (r'^admin/', admin.site.urls), URL (r '^app01', include ('app01.urls')] Passing additional options to the Vi
1. SettingsWe created the Django Project tutorial, and the app QuickStart: # Create a new Django Project Django-admin. # Use Virtualenvwrapper to create virtualenv# install Django and Django REST Framework # in Env tocreat
Background: Based on the huge demand for visualizations and cost factors, using the Pyecharts + Django visualization is clearly a better choiceVisualize to find: patterns, relationships, and anomaliesEnvironment: People with obsessive-compulsive disorder have always used the latest versiondjango:2.1.0python:3.x (Win10 is 3.7,ubuntu is 3.5)Operating system environment: WIN10 and Ubuntu1. Django Installation:
This article mainly introduces the Django framework running on Apache through mod_python configuration. Django is the most popular Pythonweb development framework. For more information about how to configure Django Based on mod_python, install Apache with the available mod_p
This article mainly introduces the Django framework running on Apache through mod_python configuration. Django is the most popular Pythonweb development framework. For more information about how to configure Django based on mod_python, install Apache with the available mod_p
Tags: INF technology Inter profile source address abstract exception business Basic conceptsDevelopment process The development model uses a front-end separation model, and as a back-end developer we focus only on backend business logic development: Omit the configuration section of the Project framework setup file .... One: User part In the project development, we need to use the user model class User,django
This article mainly introduces how to compile Contact forms in the Django framework. Django is the most popular among the frameworks with different Python characteristics, for more information, see the example form that we have been using for book search and can improve it perfectly. However, this is quite simple: it only contains one field, q. In this simple exa
The Django framework uses ajax to implement the batch data import function, djangoajax
The example in this article shows how to use ajax to import data in batches on the webpage for your reference. The details are as follows:
Url. py code:Copy codeThe Code is as follows: url (R' ^ workimport/$ ', 'keywork. views. import_keywork', name = 'import _ keywork ')View. py code:
From keywork. models import DevDataf
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.