Python development Environment (3): Create a Django project using the Eclipse+pydev plugin

Source: Internet
Author: User
Tags sqlite database java web

OS: Windows 10 Home Chinese version,Python: 3.6,Eclipse: oxygen.1a release (4.7.1A),

PyDev: 6.3.2,Django: 2.0.3

This article shows how to create the first Django project using the Eclipse+pydev plugin, as follows:

1. Menu File->new->project ... ;

2. Open the NewProject window, select Pydev->pydev Django Project in the Wizards selection box, click Next;

3. Enter the project name Edjango, select Interpreter (3.6 is selected when the Python project was previously established), and then select "Don t configure

PYTHONPATH (To is donw later on) "( note that this option may have an impact on the deployment project on-line ), click Next;

4. Open the reference page, do not select, click Next;

5. Select the Django version, keep the default 1.4 or later; Configure the database, leave the default (the following describes the modification method ); click Finish;

6.Django Construction Completed!

7. Run a new Django project to check for success-the results show that the Django Project was built successfully!

Right-click on the project name, Run as->pydev:django;

Console display such as-start success;

Browser access page--access success;

Access the console window after the page--normal;

------

note that using Pydev to create a new project, there are some differences between the project-related files and directories, as described in the previous blog post, with the command-line Django project:

. settings directory,. project file, and. Pydevproject.

Note that the default SQLite database-an embedded database-is selected when the project was built, but we are more likely to use large databases such as MySQL, PostgreSQL, and so on when we are online.

So, how do you change it? After experimentation, it is not possible to modify the project's Properties dialog box, but to modify or configure other databases directly by modifying the project's settings.py file .

Ben.z

Some of the instructions that Django uses for MySQL can be found in the official links section below: The figure mentions Django support version 5.5 and later, requiring the database to support Unicode (UTF-8 encoding)

------

More importantly, the project encoding method, Python file Encoding way!

Checking the encoding of the project found it to be GBK, because the default encoding for Eclipse is GBK (it's clear from the previous blog). Because Python 3.6 supports encoding of Unicode, Python files by default

The default mode is UTF-8, so you can set the encoding of the project to UTF-8, and it must be set, regardless of whether Eclipse has set the workspace encoding as UTF-8, and cannot retain the default secondary

Cheng inherited way !

After setting up here, the code for the Python file under the project is also programmed UTF-8.


It is important to note that this time to change the encoding method is the first time after the creation of the project changes!

To ensure that all items are initially encoded as UTF-8, you can change the encoding format of the Eclipse workspace to a fixed UTF-8to ensure that the default encoding format for new projects is UTF-8.

Do you have to do this step? After all, the impact is great! Since Java and Python support Unicode and choose UTF-8 encoding, I think it is necessary to do this step!

Menu Window->preferences under general->workspace;

Change the default encoding format for Python files in native Eclipse to UTF-8;

Menu Window->preferences under General->content Types, locate the Python file, select *.py (Locked) in File associations, and then in the default Encoding input UTF-8 can be;

At this point, eclipse+pydev development environment is also set up, follow-up is how to develop the problem of Python engineering.

==

There are still some problems:

How does the Django Project go Live (deploy)? How do you work with team development? How is the program debugged? What does unit testing do?

The Django project started and did not configure the HTTP server like the Java Web, why?

Python development Environment (3): Create a Django project using the Eclipse+pydev plugin

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.