Developing Web projects with Pycharm+django

Source: Internet
Author: User

Pycharm is a Python business integration development tool, I feel that Python development is still very useful, Django is a popular Python web open source framework, this article is to use Pycharm+django to develop a Python Web project, Start directly below

1. Install Pytcharm and Django, there is nothing to say about the installation, in the Windows environment with the installation of general software is no big difference, the main point to note is that after the installation of Django need to set the PATH environment variable, Make sure you can use Django in any directory.

2. All programming languages do not seem professional from Hello World (joke), so let's start with HelloWorld.

2.1. In a DOS environment, go to the directory where you want to put the project, create the project with django-admin.py, for example, I want to create a Hello World project under D:\, then I enter into the DOS environment d:\ Under Execute the following command: django-admin.py startproject HelloWorld such as:

After successful execution, a HelloWorld folder is generated under D:\

2.2. Open the project with Pycharm

File-->open--> Select D:\helloworld

So we can open up the HelloWorld project.

2.3. Run the project. Actually, it's ready to run.

Once saved, run directly, this project can be run up!

2.4. Next we'll create the first app. Execute DOS command in the project directory: django-admin.py Startapp SayHello, a SayHello app is created in the project's folder.

At the same time we can also see this app in Pycharm, we can write our code in the views.py file under the SayHello folder: Add the following code:

DateTimehttpresponseSayHello (Request):    ' Hello world! ' Current_time = Datetime.datetime.now ()    % (S, current_time)    HttpResponse (HTML)

Then modify the urls.py file in the project folder, add the URL (R ' ^sayhello/', SayHello), map to Urlpatterns, then restart our project, enter HTTP +//in the browser 127.0.0.1:8000/syahello will see our results.

At this point we use the Pycharm+django development environment has been set up, we can be a skill!

Developing Web projects with Pycharm+django

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.