Python uses Pycharm to create a Django project, pycharmdjango

Source: Internet
Author: User
Tags django server

Python uses Pycharm to create a Django project, pycharmdjango

This article briefly introduces how to create a Django project. For more details about how to create a Django project, refer to the following Tutorial:

Django getting started and practice-http://www.bkjia.com/article/64109.htm

Pycharm version: Professional 2017.1

Django version: 1.8.7

After the software installation and environment configuration are complete, open Pycharm.

Step 1.Click

File --> New Project:


In the figure, "1" indicates the project location. "2" indicates the template language type used. The default value is the Django template language. "3" indicates the name of the folder that saves the html of the project page. The default value is templates; 4 is the application name, which is generally named based on the actual functions of the Web application. In this example, the project is located at E: \ testDjango and the Application name is fakeCSDN. After completing the settings, click Create in the lower-right corner to Create a project.

Step 2.Shows the interface after the project file structure is successfully created:


Directory structure

  1. Manage. py: a command line tool that allows you to interact with Django projects in multiple ways
  2. Inner Directory: Real Python package of the project
  3. _ Init _. py: An empty file that tells Python that the directory should be treated as a Python package
  4. Settings. py: project configuration
  5. Urls. py: project URL Declaration
  6. Wsgi. py: entry to the Web server compatible with WSGI
  7. Templates: html file of the project

As you can see, there are three folders under the project root directory: fakeCSDN, templates and testDjango, and a python script file manage. py.

FakeCSDN is the folder for the elements related to the application we created, and testDjango is the folder for the related elements of our entire Django project. That is to say, for a Django project, there can be only one folder with the same project name, And the folder corresponding to the application can have more than one. The templates folder is used to save the HTML template.

Manage. py is a Django project management program automatically generated by the system. All commands required for creating and running Django projects can be provided by this script. For example, create makemigrations and migrate databases for the project, and start the runserver of the server. Manage. py does not need to be modified during programming.

FakeCSDN and testDjango have roughly the same content.

In fakeCSDN, the migration folder, models. py, and views. py are commonly used in programming.

  1. Views. py is the core of the Web application background. It defines the specific response actions and data access and operation functions in the background;
  2. Models. py is the definition file of the Web application database. It defines tables in the database in the form of Python classes;
  3. The migration folder stores the files after the database tables in models are migrated. Generally, manual operations are not required.

In addition to existing files in fakeCSDN, you need to create a new urls. py file to specify the response function corresponding to the url in the application.

In testDjango, common files are setting. py and urls. py. The former is some property settings of the project, such as database connection and debug mode, and the latter is also a url ing relationship.

Step 3.Edit Web application details

Step 4.Configure the Django Server and start the Server. Click the green button shown in the figure to start the Web application.


If the icon does not appear automatically, click the gray triangle down and select Edit Configurations. In the displayed window, add a new Django Server in step 1 and enter the Server name in step 3, enter the startup page in step 5. Click OK.

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.