Django Administration Tool django-admin.py creating a project

Source: Internet
Author: User

After installing Django, you have installed the available management tools django-admin.py, which you can use to create projects and run django-admin.py to view the command description:

See how one of these commands are used:

Create a new project:

To view the directory structure:

Catalogue Description:

    • HelloWorld: the container for the project.
    • manage.py: a useful command-line tool that allows you to interact with the Django project in a variety of ways.
    • helloworld/__init__.py: An empty file that tells Python that the directory is a python package.
    • helloworld/settings.py: setup/configuration for this Django project.
    • helloworld/urls.py: URL declaration for the Django project; A "directory" of Django-driven Web sites.
    • helloworld/wsgi.py: a WSGI-compatible WEB server's portal to run your project.

Next we go into the HelloWorld directory and enter the following command to start the server:

Python manage.  0.0.  0.0:8000

0.0.0.0 allow other computers to connect to the development server, 8000 is the port number. If not stated, the port number defaults to 8000.

In the browser input your server's IP and port number, if normal startup, the output is as follows:

Create a view.py file under Path C:\Users\XCC\HelloWorld\HelloWorld, and enter the following code:

 from Import HttpResponse def Hello (Request):     return HttpResponse ("")

Bind the URL with the view function, replacing the code in the original urls.py with the following code:

 from Import * fromimport= Patterns ("",    ('^hello /$', hello),)

Entire Directory structure:

After starting the Django Development server, access in the browser:

Note: If the code changes in the project, the server will automatically monitor the code changes and reload automatically, so if you have already started the server, you do not need to restart manually.

Django Administration Tool django-admin.py creating a 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.