Python study note 23: setting up a simple blog website with Django (1)

Source: Internet
Author: User
Tags django website

Python study note 23: setting up a simple blog website with Django (1)

 

1. Create a project command: Django-admin startproject mysite
# Some need to enter: Django-admin.py startproject mysite


You will find that a folder mysite is generated under the current directory, and its structure is:
Mysite/
Manage. py
Mysite/
_ Init. py
Settings. py
Urls. py
Wsgi. py



Where:
Manage. py: a command line tool that can call Django shell and database. Type python manage. py-h to view its functions.
_ Init _. py: Let Python treat this directory as a file required by an Development Kit (that is, a group of modules. This is an empty file. You do not need to modify it.
Settings. py: the default settings of the project, including the database information, debugging flag, and other working variables.
Urls. py: Set the URL of the django project. It can be viewed as the directory of your django website and is responsible for ing the URL mode to the application.
Wsgi. py: A simple and common Interface between a Web Server and a web service program or framework.




2. Run the following command in the mysite Directory: python manager. py runserver
If an error occurs:
XXX
You have unapplied migrations; your app may not work properly until they are applied. Run 'python manage. py migrate' to apply them.
XXX
Obviously, we have already told you how to do this. Execute python manage. py migrate.
What does migrate do? It allows us to reconstruct the table structure without affecting the existing data after modifying the Model.


The following output is displayed:
Operations to perform:
Apply all migrations: admin, contenttypes, auth, sessions
Running migrations:
Applying contenttypes.0001 _ initial... OK
Applying auth.0001 _ initial... OK
Applying admin.0001 _ initial... OK
Applying sessions.0001 _ initial... OK

You will find that the file dg. sqlite3 is added to the mysite directory on the previous layer.

(Or Add the following sentence in settings. py: TEST_RUNNER = 'django. test. runner. DiscoverRunner')

 

Then run the server again, with the following output:

System check identified no issues (0 silenced ).
October 23,201 4-01:20:03
Django version 1.7.1, using settings 'mysite. setting'
Starting development server at http: // 127.0.0.1: 8000/
Quit the server with CONTROL-C.

The running server is successful.




3. In the browser, enter 127.0.0.1: 8000.
You can see the image shown in:

 

 



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.