Python Learning note 23:django building a simple blog site (i)

Source: Internet
Author: User
Tags django website install django

The previous section describes how to download and install Django, a section that will focus on how to run a Web site using Django creation.


A new Project command: django-admin startproject MySite
# Some need to enter: django-admin.py startproject MySite


This is what you will find in the current directory, a folder MySite is generated, and its structure is:
mysite/
manage.py
mysite/
__init.py
settings.py
urls.py
wsgi.py



which
manage.py: A command-line tool through which you can invoke the Django shell and database. Type the Python manage.py-h to see its related features.
__init__.py: Let Python treat the directory as a required file for a development package (that is, a set of modules). This is an empty file, generally you do not need to modify it.
settings.py: Default settings for the project, including database information, debug flags, and other work variables.
The URL setting for the Urls.py:django project. As a directory of your Django website, it is responsible for mapping the URL pattern to the application.
wsgi.py: A simple and common interface between a server gateway interface (Python Web server, Gateway Interface), a Web server and a Web service program, or a framework.




Two run server MySite (previous layer) directory execution command: Python manager.py runserver
If an error occurs:
Xxx
You have unapplied migrations; Your app properly until they is applied. Run ' python manage.py migrate ' to apply them.
Xxx
It's obvious that we've been told what to do, so execute it: Python manage.py migrate
What does this migrate do? It allows us to reconstruct the table structure without affecting the existing data after modifying the model.


You can see the following output:
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

This is where you will find one more file under the MySite directory on the previous layer Dg.sqlite3

(Or, in settings.py, add this sentence: test_runner = ' Django.test.runner.DiscoverRunner '


Then run the server again and you have the following output:

System Check identified no issues (0 silenced).
October 23, 2014-01:20:03
Django version 1.7.1, using Settings ' mysite.settings '
Starting development Server at Http://127.0.0.1:8000/
Quit the server with Control-c.

Indicates that the server is running successfully.




Three Tests in the browser input: 127.0.0.1:8000
You can see the screen as shown:


In the next section, how to add a blog app to our site.




Python Learning note 23:django building a simple blog site (i)

Related Article

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.