The text and images in this article from the network, for learning, communication purposes, not for any commercial purposes, the copyright belongs to the original author, if there is any problem, please contact us in a timely manner in order to deal with.
The following article is from Python Practical Treasure , by Python Practical Treasure
Pycharm has powerful configuration tools, Git version management tools, code completion tools, Debug tools and so on, which are all great tools for large-scale project development.
In particular, today's protagonist, Django, is so important that Pycharm has even dedicated a configuration template to it:
You can select Django directly when creating a new project and create a separate virtual environment:
From new construction to coding and testing, the set of processes is extremely easy to use.
1. Download Pycharm
Download Pycharm by selecting the appropriate system from the jetbrains website:
/pycharm/download/
It is highly recommended to download the Professional version (Professional Edition), the activation method can be checked on the Internet by yourself, recommend the article of Brother Knowledge ().
After the installation is complete, there are two ways to configure the Django project depending on whether you need to create a new one or not.
1.1 Create a new Django project
File-New Project creates a new Django project:
It is highly recommended to create a new environment, the default tool to create a new environment is Virtualenv, here I use conda, the effect is actually similar. The difference is that conda allows you to choose the Python version.
Enter a good location (installation location) and click create, you can generate Django project.
1.2 Configuring a Developed Django Project
Adapting an already developed Django project in Pycharm is also very easy, as it provides configuration templates specifically for this case:
Click on the configuration box in the upper right corner and select Edit Configurations.
When you come in, first enter Name the project name, then select the compiler of the environment your code belongs to in Python Interpreter, and finally select Fix to bring up the Django configuration page.
Enter these three items in the configuration page that appears after clicking Fix:
The first is the project root directory, the second is the location of the file, and the third is the location. You can't have one without the other. Click OK when you're done and the configuration is complete.
2. Running the project
Pycharm runs Django projects by simply clicking on one of these two in the upper right corner:
The first is the normal startup mode, the second is the Debug startup mode, the second is recommended, because if you need to trace the code flow when developing, Debug mode is very convenient.
After clicking it, the command to start Django will be generated automatically, you can view the statement in the console, and the following output will appear, i.e. the startup is complete:
Visit http://127.0.0.1:8000/It's the front page of the site..
The default port number used here is 8000, you can change the default domain name and port in the configuration page, except for other domains you need to direct them to 127.0.0.1 in hosts, e.g..
Modify the hosts file by adding: 127.0.0.1
Save and then modify the configurations configuration in the upper right corner:
Add this domain to ALLOWED_HOSTS in:
This will give you access to your development environment via :5555/:
3. Tools
Here are some of the tools that are unique and special to Pycharm:
3.1 It is very easy to view the history of document modification and submission records:
Click on each submission to see the content of each submission.
3.2 Selecting a Specified Commit Line
VCS-Commit, which gives you the freedom to choose the block of code you need to commit:
3.3 Automatically Formatting Codes
3.4 Global search
Although VSCode also has global search, trust me, they two are not the same concept:
Choose Ctrl+shift+F on windows to search globally in Pycharm, or find it in Edit-Find-Find in Path:
The interface is as follows. It not only searches globally, but can also specify modules and directories to search.
Specify the file name search , advanced filters can also search for specified in addition to the comments in line with the keywords of the sentence , etc., is a very powerful search tool .
This search tool is second only to the Debug tool for me in terms of frequency of use.
Pycharm in the very useful production tools and many more, simply can not be used, next time to give you a detailed introduction to a number of
To this point, this article on the detailed Pycharm installation and Django installation configuration guide to this article, more related to Pycharm installation Django installation configuration content, please search for my previous posts or continue to browse the following related articles I hope you will support me in the future more!