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)