Django Learning (vii) Create a first Django project

Source: Internet
Author: User

If this is your first time using Django, you have to do some initial setup. That is, you will need to automatically generate some code to build the Django project.

From the command line, CD into a directory, you want to store your code, and then run the following command:

Django-admin Startproject MySite

This will create a directory for MySite in the current directory. In this created MySite folder, the default contains some files, the file structure directory is as follows:

mysite/    manage.py    mysite/        __init__.py        settings.py        urls.py        wsgi.py

1, the outer layer for MySite/root directory for your project is just a container. Its name doesn't matter, you can rename it to any name you like.
2. manage.py a command-line utility that allows you to interact with this Django project in different ways.
3, the inner layer MySite directory is the actual Python project.
4, mysite/__init__.py, an empty file, which is designed to tell Python that this is a directory that should be seen as a Python program.
5. configuration file for Mysite/setting.py,django project
6. URL Declaration of the Mysite/urls.py,django project; "Directory" of the django-powered site.
7, mysite/wsgi.py, for this project is a WSGI entry point. (may not explain,????? )

Run the Django program:

Python manage.py
You will then see the following print information on the console:
    
Performing system checks ... 0 Errors Foundjune, 2015-15:50:53django version 1.8, using Settings ' mysite.settings ' starting development Server at H Ttp://127.0.0.1:8000/quit the server with Control-c.

You can then enter http://127.0.0.1:8000/in the browser input field to see the Django Welcome page.
You can also specify the port number that the service starts: Python manage.py runserver 8080
If you want it to be accessible within the LAN, you can execute the python manage.py runserver 0.0.0.0:8080

In addition, if the Python file is modified, the Python service does not need to be restarted and Runserver will reload automatically. However, if it is a new Python script file, you will need to restart the Python service.

Django Learning (vii) Create a first Django project

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.