Start a Django Project

Source: Internet
Author: User

System: Mac osx10.10.3, Django version: 1.8.1
1. Under terminal Enter the destination folder, run Django-admin startproject projectname. After the command finishes running, a project named ProjectName is created under the current directory. The project contains a folder with the same name (ProjectName) and a manage.py file. Subfolders projectname contain files such as Profiles settings.py and urls.py.

2. After entering the ProjectName project, run the Python manage.py startapp appname command. After execution, an app named AppName is created in the current project.

3. Open the settings.py file mentioned in the first step, locate the Installed_apps configuration, and add the appname.

4. Add the folder templates under the AppName app and create the app's Web page under this folder, such as Index.html. The following is an example of index.html.

5. Add the method func that handles the index.html request in the appname views.py file.

6. Add the URL (r ' ^index ', func) in the urlpatterns of the urls.py file mentioned in the first step. The func here is the same method as the Func method in the views.py file.

In this way, a simple application is completed. Exit to the project Ask folder, execute Python manag.py runserver run the local server. Then enter the URL http://127.0.0.1:8000/index on it.

Start a 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.