Python manage.py runserver 0.0.0.0:8000Run the program locally, python manager.py runserver open the http://127.0.0.1:5000 port view, press CTRL + C to exit the program.At this point, the default only local access to the site, if you need other people can also access, you need to specify 0.0.0.0 this IPWe need to add t
Solve the error that occurs when centos executes the python manage. py runserver command.You are going to install django in CentOs. However, the following error occurs when you execute the python manage. py runserver command:
Django. core. exceptions. ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 mod
is because the Django settings automatically load the configuration file. You can add--noreload after running the command so that only one process is displayed, but after modifying the file, Django does not actively load the configuration file.if settings.py is Debug=false, Django will not process the static file, which can be used to force Django to process static files using the--insecure parameter .Python manage.py
gateway, that is, gateways. The purpose of a gateway is to convert between protocols.
WSGI is a low-level interface between a Web server and a Web application or application framework to enhance the common denominator of portable web application development. WSGI is designed based on the existing CGI standards.
Many frameworks have their own WSGI servers, such as Flask,webpy,django, CherryPy, and so on. Of course, the performance is not good, the Web server comes with more testing purposes, the
by the framework as long as the server program supports this standard, so they can work with it. Once the criteria are determined, both parties are implemented. In this way, the server can support more frameworks that support standards, and the framework can use more servers that support standards.WSGI (Web server Gateway Interface) is a specification that defines the interface format between Web apps and Web servers written in Python, enabling decou
servers, such as Flask, webpy, Django, and CherryPy. Of course, the performance is not good. The built-in web server is mostly for testing purposes. During the release, the WSGI server in the production environment or the uwsgi with nginx is used.
The independent WSGI server provided by the python standard library is called wsgiref.
#! /Usr/bin/env python # coding: UTF-8 # import wsgi module from wsgiref.
Before looking at some articles on the web that describe the process of Django processing requests and the Django source structure, it's helpful to find out more about the Django project. So I summed up my own logic to see how the Django Project works and the basic processing process for the request.
One, Django operation mode
There are many ways to run Django projects, and here are a few of the most common methods. One is to use the Runserver metho
standards, and the framework can use more servers that support standards.WSGI (Web server Gateway Interface) is a specification that defines the interface format between Web apps and Web servers written in Python, enabling decoupling between Web apps and Web servers.The standalone WSGI server provided by the Python standard library is called Wsgiref.#!/usr/bin/Env Pyth
__name__ == '__main__': manager.run()
Extensions designed for Flask are exposed in the flask. ext namespace. Flask-Script exports a class named Manager from flask. ext. script.
The method for initializing this extension is the same as that for many other extensions: the initialization of the main class instance is implemented by passing the application instance as a parameter to the constructor. The created object is suitable for each extension. In this example, the server is started to route
initialization of the main class instance is accomplished by passing the application instance as a parameter to the constructor. The objects created are appropriate for each extension. In this example, the server starts routing through Manager.run (), and the command line is parsed here.
Recommendation: If you have cloned apps on GitHub, you can now run git checkout 2c to switch to this version of the app.Because of these changes, the application obtains a basic set of command-line options. Run
development of the use of general code changes will be automatically restarted, convenient debugging and development, but due to performance issues, it is recommended only for testing, do not use in the production environment.$python manage.py runserver # 当提示端口被占用的时候,可以用其它端口:$python manage.py runserver 8001$
Objective
Traditional Web development methods often need to write tedious repetitive code, not only the page performance and logic implementation of the code mixed together, and code writing efficiency is not high. For developers, the choice of a powerful and simple development framework to assist in the implementation of complex coding work, will be a great help to improve the efficiency of development. Fortunately, such a development framework is not uncommon, and all that needs to be done is
djangodjango.get_version()
Create a django Project
django-admin.py startproject mysite
At this time, some directories and files are automatically generated, and the manage. py at the outermost layer is like a running entry. Through the command line call, you can complete some common functions, such:
Running django's built-in web server:
python manage.py runserver http://127.0.0.1:8080
Common synchronizatio
booklist(request): list = Book.objects.all() return render_to_response('booklist.html',{'books':list})
8. modify the content of d: \ mysite \ url. py. The result is:
urlpatterns = patterns('', ('^hello/$','mysite.views.hello'), ('^books/$','mysite.books.views.booklist'),)
9. create a new sub-directory templates under the D: \ mysite directory as the Directory for storing the template.
Create a new template file booklist.html with the following content
{% for book in books %}
step: Configure the URL.Now, if you run again: Python manage.py runserver, you'll also see the Django Welcome page without seeing the Hello World display page we just wrote. That's because our MySite project also knows nothing about the Hello view. We need to explicitly tell it and activate this view through a URL that is described in detail. To bind the view functions and URLs, we use urlconf, the urls.py
Many beginners ask how Python and Django are installed, so here's a quick introduction to the two software installation steps under Windows 2003.First, download and install PythonPython official: http://www.python.org/ftp/python/We have chosen Python 2.7.2 here. Although the latest version is Python 3.2.2, Django does
configuration file, and the templates directory is the HTML file that is the T in MTV. Manage.py is a Django project management file.3. Create an appYou can include multiple apps in each Django project, like sub-systems, sub-modules, features, and so on, in a large project, independent of each other, but also associated.All apps share project resources.Enter the command in the terminal terminal below Pycharm: Python manage.py Startapp CMDBThis creat
process. Developers can simply enter the project directory at the command prompt, type the command manage.py runserver, start the Web server to test the newly created project, and if it starts without errors, you will see a message like this: "Development server is Running at Http://127.0.0.1:8000/"indicates that the current project is already accessible via the 8000 port on this machine. Open the above address via the browser, and the initial page o
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.