1. Installation Requirements
When using the python framework Django, you need to pay attention to the following
Pycharm version is professional version not community version
Pycharm has configured the python interpreter (generally we are using python3 now)
I am using Pycharm version 2020.1.2
2. Preparations
2.1 Create a new project First we open Pycharm as shown below
Some friends may know how to open this interface, you can do this, open your Pycharm compiler, and then click File -> Close Project in the upper left corner
2.2 Input related configuration
Just follow the prompts in the picture below. After the configuration is complete, click Create
2.3 The project is created
This is installing the Django framework, just wait for a while
The installation is complete as shown below
2.4 View and install Django version
Select Terminal at the bottom of Pycharm and enter: python -m django --version
(pytorch_gpu) D:\python-workspace\tutorial>python -m django --version
3.2
2.5 Start the project
Enter in Terminal: python manage.py runserver
Then the following small error occurs
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "D:\Python\Anaconda\envs\pytorch_gpu\lib\site-packages\django\core\management__init__.py", line 419, in execute_from_command_line
utility.execute()
File "D:\Python\Anaconda\envs\pytorch_gpu\lib\site-packages\django\core\management__init__.py", line 363, in execute
settings.INSTALLED_APPS
File "D:\Python\Anaconda\envs\pytorch_gpu\lib\site-packages\django\conf__init__.py", line 82, in __getattr__
self._setup(name)
File "D:\Python\Anaconda\envs\pytorch_gpu\lib\site-packages\django\conf__init__.py", line 69, in _setup
self._wrapped = Settings(settings_module)
File "D:\Python\Anaconda\envs\pytorch_gpu\lib\site-packages\django\conf__init__.py", line 170, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "D:\Python\Anaconda\envs\pytorch_gpu\lib\importlib__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\python-workspace\tutorial\tutorial\settings.py", line 57, in <module>
'DIRS': [os.path.join(BASE_DIR, 'templates')]
NameError: name 'os' is not defined
复制代码
solution
Find the seeings. py file, and then add: import os to the header of the settings.py file
Execute again: python manage.py runserver
When the above interface appears, the Django project is basically built.
2.6 Solve a little problem
When I started the Django project, I found that the following little prompt appeared in the console
You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run ‘python manage.py migrate’ to apply them.
I don't understand the reason for this problem, and I will directly give you a solution.
Solution: First Ctrl + C to end the service, execute this command python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying auth.0012_alter_user_first_name_max_length... OK
Applying sessions.0001_initial... OK
复制代码
This is done.
Digression
In this first year of fast-growing technology, programming is like a ticket to a world of infinite possibilities for many people. In the star lineup of programming languages, Python is like the leading superstar. With its concise and easy-to-understand syntax and powerful functions, it stands out and becomes one of the most popular programming languages in the world.
The rapid rise of Python is extremely beneficial to the entire industry , but " 人红是非多
" has caused it to add a lot of criticism, but it still cannot stop its hot development momentum.
Will Python remain relevant and intact for the rest of the next decade? Today, we're going to analyze the facts and dispel some misconceptions.
If you are interested in Python and want to get a higher salary by learning Python, then the following set of Python learning materials must be useful to you!
Materials include: Python installation package + activation code, Python web development, Python crawler, Python data analysis, artificial intelligence, machine learning and other learning tutorials. Even beginners with 0 basics can understand and understand. Follow the tutorial and take you to learn Python systematically from zero basics!
1. Learning routes in all directions of Python
The route of all directions in Python is to organize the commonly used technical points of Python to form a summary of knowledge points in various fields. Its usefulness lies in that you can find corresponding learning resources according to the above knowledge points to ensure that you learn more comprehensively.
2. Python learning software
If a worker wants to do a good job, he must first sharpen his tools. The commonly used development software for learning Python is here!
3. Python introductory learning video
There are also many learning videos suitable for getting started with 0 basics. With these videos, you can easily get started with Python~
4. Python exercises
After each video lesson, there are corresponding practice questions, you can test the learning results haha!
Five, Python actual combat case
Optical theory is useless. You have to learn to type codes along with it, and then you can apply what you have learned in practice. At this time, you can learn from some practical cases. This information is also included~
6. Python interview materials
After we have learned Python, we can go out and find a job with the skills! The following interview questions are all from first-line Internet companies such as Alibaba, Tencent, and Byte, and some Alibaba bosses have given authoritative answers. After reading this set of interview materials, I believe everyone can find a satisfactory job.
7. Information collection
The full set of learning materials for the above-mentioned full version of Python has been uploaded to the CSDN official website. Those who need it can scan the QR code of the CSDN official certification below on WeChat to receive it for free.