First, make sure that python is installed on your machine. Second, make sure that Django is installed on your machine.The next step is to build the first Django application.A simple operation is to enter the code on a windows terminal:Copy codeThe Code is as follows:1 django-admin.py startproject mysiteYou can, for
contains the code snippets associated with the template, and the appropriate line highlighting is used.
Note that if debug is True,django only the cute error page will be displayed.
See also DEBUG.
Template_dirs
Default: () (Empty list)
Since version 1.8, it is not in favor of using:
Set the ' dirs ' option in a djangotemplates engine instead.
Django.template.loaders.filesystem.Loader Search the path list for the source code of the template, s
associated with the template, and the appropriate line highlighting is used.
Note that if debug is True,django only the cute error page will be displayed.
See also DEBUG.
Template_dirs
Default: () (Empty list)
Since version 1.8, it is not in favor of using:
Set the ' dirs ' option in a djangotemplates engine instead.
Django.template.loaders.filesystem.Loader Search the path list for the source code of the template, sorted by search order.
Not
generates test data for the Django model through the Faker Library, which supports the latest versions of Python and Django.Django-tenantsSummary: Django-tenants allows Django-driven Web sites to support multiple tenants, a feature that is implemented through PostgreSQL schemas. This is the core feature of every sass
InstallationDjango is a Python-language environment, so make sure you have Python installed on your computer first.LinuxUbuntu:sudo pip install django==1.11.7A version is specified in the installation, you can modify the version number, or you do not specify that the version that is already in the software source will be installed.Once the installation is complet
Django, while Django only supports 2. x version, so I installed 2.7.7. After you select a version, you will be redirected to the supported system selection page. You can select different versions based on the system. If 32-bit Python is installed on 64-bit systems, many errors may occur. Especially when MySQL support is installed later, the system prompts that
)?
Solution: Add blank = True, for example, parent = models. ForeignKey ('self ', null = True, blank = True, verbose_name = "parent class ID ")
5. Since Python django applications are always recommended to use PostgreSQL databases, they are also excellent open-source databases, so we need to learn how to use them. Django
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
request Source Address Request.path_infoRequest. Files File UploadBecause of the Request. Files are very special, after the file upload, through the Django Request.POST.get () only the filename string, we can customize a file upload method1) add enctype attribute to form form attribute2) Custom Upload in viewsImport osobj = Request. Files.get ("a_file") printf (obj) # New upload storage file in Django work
Advanced knowledge points include:
Static file Processing
Middleware
Upload image
Admin site
Page out
Using jquery to complete Ajax
Managing Static Files
CSS, pictures, js are static files in the project
Configuring Static Files
Defining static content in the settings file
STATIC_URL = ‘/static/‘STATICFILES_DIRS = [ os.path.join(BASE_DIR, ‘static‘),]
Create a static directory under the project root and create a directory f
This article focuses on the simple use of the Simple-todo tool in the Python Django Framework, which is based on the Open-source project in the original web.py, and the friends you need can refer to the
Origin
Simple-todo was the earliest example of a Chinese web.py tutorial. Later, Uliweb's author Limodou that the tutorial was very good, so there was a uliweb
for future reading. (Note:Don't get stuck in an endless loop)
Now you know what the knowledge points are and what books you need to read. ThenRelax and watch some simple thingsFor example, the Django document first-steps Django documentationWrite a small program once. If you encounter unfamiliar web Front-end knowledge points during this period, you can repeat
need to add the form and input tags
Verify
Receive the requested information, as compared to the content in the session
from django.http import HttpResponsedef verifycodeValid(request): vc = request.POST[‘vc‘] if vc.upper() == request.session[‘verifycode‘]: return HttpResponse(‘ok‘) else: return HttpResponse(‘no‘)
Configure the URL for validation processing
urlpatterns = [ url(r‘^verifycodeValid/$‘, views.verifycodeValid),]Third party
$. Get () for get requests without the preceding operations.Note: This document uses Django1.8.3 for testing.
The above is all the content of this article, hoping to help you learn.
Articles you may be interested in:
Use the Python urllib library to submit WEB forms
Tutorial on web forms in the Python Flask framework
Example of form processing in the
lower]
isupper
is the string all uppercase? [Also see islower, and so forth]
Formatted output:>>> '%s is number%d ' percent (' python ', 1) ' Python is number 1 ' >>> hi = ' hellobaby ' >>> hi ' hello\n Baby ' >>> print HihellobabyTuplesThe elements inside a tuple cannot be modified, which is related to its own implementation mechanism, and it is a good choice to pass par
Django + Vue. js: An example of building the frontend and backend Separation Project, djangovue. js
At the time of writing this article, I learned how to use Markdown.
I am a scum, and everything is learned by myself, so there is no system or system learning. The main purpose here is to split the frontend and backend of the project.
Assume that django and vue. js
As a. NET programmer, I really don't like PHP's loose syntax. Some people say that programmers should learn a few more languages and want to learn Java, but they feel that the syntax of Java is too long. Many people recommend Python, which has simple syntax and high execution efficiency. In the past two days, I started to learn Python. Start with setting up the environment. As a beginner in
need to know about Django's Unicode support will make it easy for your application to handle a wide variety of character sets, not just basic A-Z English characters.
Dictionary and Contexts
The dictionary data type of Python is a ing between keywords and their values. Context is similar to the dictionary. Context also provides more functions.
The variable name must start with an English character (A-Z or a-z) and can contain numbers, underscores, and
This article mainly introduces the Django cross-domain request processing sample code, has a certain reference value, now share to everyone, the need for friends can refer to
Django handles Ajax cross-domain access
When using JavaScript for AJAX access, the following error occurs
Cause of error: JavaScript is safe and does not allow cross-domain access. is an explanation of cross-domain access:
Concept:
This article describes how to write error prompt pages in the Python Django framework, including the traditional 404 page and setting connection interruption warnings, for more information, see TEMPLATE_DEBUGFalse in the production environment. If this parameter is set to 'true', You need to display enough information on the nice-looking error page, the Django te
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.