differentiate the matching pattern, and int: then a converter determines what variable type should match the URL path of that part.Adding unnecessary things to each URL, for example .html , is not necessary. But if you have to add it, it's also possible:Path ('votes/latest.html', Views.index),But, don't do this, it's stupid.3. Next, write a real viewHere's a question: the design of the page is written in the code of the view function. If you want to
the C:/python25/myproj directory:[Python]View Plaincopy
From django.http import HttpResponse
def index (Request):
return HttpResponse (' Hello, django! ')
Configuring the urls.py File[Python]View Plaincopy
From Django.conf.urls.defaults Import *
# Uncomment the next lines to enable the admin:
# from Django.contrib Import a
template system, depend on the configuration file. If Django does not know which configuration file to use, these systems will not work.
If you want to know, I will explain how it works. Django searches for the DJANGO_SETTINGS_MODULE environment variable, which is set in settings. py. For example, if mysite is in your Python
First Django-based page: Hello WorldAs our first goal, create a Web page that is used to output this famous example message: Hello world. First viewThe Hello world view is very simple. These are the complete functions and import declarations, which are entered into the views.py file:1 from Import HttpResponse 2 3 def Hello (Request): 4 return HttpResponse ("Hello world!\nit ' s my first
the new installed version of Python, by default the new version of/usr/local/bin/is usually the same as the previous version of the Python location. You can check the Ls-al
Set the new version to the default version under/usr/bin/to set a new version of soft connect ln-s/usr/local/bin/python3.4/usr/bin/python
3. The following is the installation of
Python framework and Web servers) standard to ensure the portability of applications. Although Django 1.0 has not been available for a long time, many Python developers are still optimistic about this framework, and successful cases of Django development are also increasing. According to the materials provided by
on "Environment variables" in the system variable, find path, double-click, then the end of the string, plus a semicolon;Then enter your path to install Python, OK, OK, until the setup is complete, open the command line, enter Python, the following prompt is the configuration success3 , install Django after Django is
Django's automatic management interface. This feature works: it reads the metadata in your schema and provides you with a powerful and accessible interface that the site manager can use to work immediately.
Please note that we recommend that you read this chapter even if you do not intend to use admin. Because we're going to introduce a few concepts that can be applied to all aspects of Django, not just the adminDjango.contrib Bag
The
version of Python)#!/usr/bin/python2.6Then save OK.Second, installation UwsgiDownload the latest version of Uwsgiwget http://projects.unbit.it/downloads/Because I ended up using XML to configure the Django app deployment, so compiling UWSGI needs to compile the libxml.Yum-y Install Libxml2-develThe rest is simple.Tar zxvf uwsgi-1.9.17.tar.gzCD uwsgi-1.9.17MakeCP Uwsgi/usr/sbin/uwsgiIf you encounter an erro
Django is an open-source Web application framework written in Python. It was initially developed to manage some websites dominated by news content under the Lawrence Publishing Group. Python + django is also the most popular framework for web developers. Today, we record the entire process of building a development env
productivity. I have to repeat SQL, write Python code, and then write SQL ,..., It will split your head.
3. Express the data model in code so that you can easily control the version of the data model. In this way, you can easily understand the changes in the data layer.
4. SQL can only describe specific data fields. For example, most databases do not have dedicated field types to describe email addresses a
About Django:Django is an Open-source Web application framework written by Python. The MVC framework pattern was adopted, i.e. model m, View V and Controller C. But in Django's actual use, Django is more concerned with models, templates, and views, called MTV Mode. The main purpose of Django is to easily and quickly develop a Database-driven website that emphasiz
A comprehensive understanding of the Python Web development Framework Djangodjango is an open-source Web application framework, written by Python. Using MVC's software design model, the main goal is to make it easy to develop complex, database-driven Web sites. Django focuses on component reusability and "pluggable", agile development and dry rules (Don ' t Repea
This article describes how to deploy the Apache + Python + Django + MySQL environment on Linux, and connect mod_python to the mysqldb module, for more information, see Linux + apache + mysql + python + mod_python + Django.
Note: httpd and mysql are installed by default in rhel 5.3. If not, download and install the RPM
reference to the property name can be used directly in the template.The selection structure is similar to Python. Depending on whether the transmitted data is True,django, select whether or not to display. Use the following methods:
{% if condition1%}
... display 1
{% elif Condiiton2%}
... display 2
{% Else%}
... display 3
{% ENDIF%}
One of the elif and else is the sam
Old Wang Python: The difference between get and filter methods of Django model _ Python tutorial _ Old Wang Python
Old Wang Python: The difference between get and filter methods of Django model Django's get and filter methods
to use, you must download and install the corresponding database adapter. Access the links in the "Required Adapters" column in table 5-1 for free access to these adapters via the Internet. If you use Linux, your release package management system will provide the appropriate package. For example, find the package "Python-postgresql" or "PYTHON-PSYCOPG".
This article describes how to wrap view functions in the Python Django framework, that is, the requires_login method, if you need it, you can refer to our final View technique and use an advanced python technology. Suppose you find that you have repeated a large number of code in different views, just like this example
variable.
If it still cannot be found, the system will throw an error that is not an internal command. The above is my personal understanding.
2. Django Installation Steps
The installation of Django is simpler. First extract the downloaded compressed package, then run the command cd in the command line to enter the Django folder, and run the command:
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.