Django Explore--django's development server and database creation (note)

Source: Internet
Author: User
Tags sqlite database

1. Django's Development server

The Django framework contains a few lightweight Web application servers that no longer need to configure the server when developing Web projects, and the built-in servers that Django provides can be loaded automatically when code is modified to enable rapid website development.

Under the directory of the Django_pro project we created, open the DOS command line and start the built-in server:

manage.py Runserver

By default, use the command manage.py Runserver to start the built-in server, use the native 8000 port by default, and if you need to use a different port (for example, 8001), use the command

manage.py runserver 8001

The above two commands are only monitored natively, which means that Django only receives connections from the local computer. When you accept a request from another host, use the command

manage.py runserver 0.0.0.0:8000

This statement indicates that all network interfaces on this computer are listening on port 8000 to meet the needs of multiple people collaborating to develop and test the Django project, as well as using other hosts to access the Web server.

Start the browser, enter http://localhost:8000, connect to this Web server, display the initialization page of the Django project, and indicate that the Django framework is properly installed and building a project.

2. Create a database

Here, we use the SQLite database engine. After you run the server, the Db.sqlite3 file is automatically generated under the folder.

  

If you do not have the file, you need to configure and create the database.

Modify the Databases dictionary in the setting.py file, configure the engine to specify a database that uses the Sqlite3 type, and configure name to specify the database file to use as Db.sqlite3

DATABASES = {'
    default ': {
        ' ENGINE ': ' Django.db.backends.sqlite3 ',
        ' NAME ': Os.path.join (Base_dir, ' Db.sqlite3 '),
    }
}

Then use the command to generate the database: manage.py suncdb, and configure the user name and password are admin

Use Sqlitemanager to open the Db.sqlite3 file in the Django_pro directory, showing the results as follows

Django Explore--django's development server and database creation (note)

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.