I will use Django framework for my graduation project, which I have never touched before. I took advantage of the winter vacation to do something about it. It took a lot of potholes, but finally it worked.

Environment: Python3.7.3 + Django 2.2 + Pycharm- professional-Anaconda-2019.3.2

Install Django

I have seen many installation methods on the Internet

  • PIP install
  • Virtualenv Virtual environment installation
  • Pycharm installation

The second kind does not understand, the first kind and the third kind have tried, found later is still the third kind convenient.

The Pycharm community version used before failed because the version did not match. The community version was later uninstalled and Pycharm for Anaconda Professional was installed.

Open Pycharm and create a new Django project

Create a new project, select Django, and give the project a name. Remember that Application name is also required, and click Create. (Note: The New project comes with Django framework, which is provided by the professional version, but the community version does not have this function. I register with the student mailbox and use it for free)

But there is a problem with the way I create it, and it reports an error:

Error creating Django application :error on python side.Exit code:1.
Copy the code

I couldn’t find a solution, so I clicked OK and entered the project, guessing that there might be a version mismatch, so I needed to modify the Django version and manually create the Application.

Change your Django version

Although Django is now version 3.0, I want to use Python3.7 + Django 2.2 to build the project. By default, the latest version of Django is installed, so I need to uninstall Django 3.0 and reinstall the specified version of Django 2.2.

First, open Settings:

Then, click Project Interpreter, click Django, and click – to delete.

To install the specified version of Django, click + on the right, then enter Django in the search box, click On the top left line of Django, check Specify version on the right, and select the version you want.

Finally click on the bottom left corner of the image Install Package, wait a moment to Install successfully.

Create Application

In Pycharm’s Terminal type:

Django-admin startApp app_name # Create appCopy the code

In addition to the pit that the second command will report an error, there is another pit to be aware of. Make sure you enter the manage.py file where it exists, as shown in the figure below:

Manage.py is in the Code folder with gradeDesign folder, not in gradeDesign folder, which is also a hole I step in.

Once you’ve created your App, the top left corner looks something like this:

V. Start the service

Again in Terminal, I’m going to say:

python manage.py runserver 8000
Copy the code

And then Terminal will look something like this:

Click on the address above to see the following page:

At this point, the Django project is basically set up.

6. Other pits

  • Check installation earlierDjango, need to be configuredThe environment variableI set it, too, but incmdIn the inputDjangoRelated code displayNot an internal or external commandI don’t know what happened.

Thank you,

Python3.7 + Django2.2 + Bootstrap4 +Pycharm2019 Getting Started 01

Pycharm+ Django2.2 + PYTHon3.6 +MySQL to implement a simple test registration system

Django2.0 Introduction tutorial: Install Django2.0

Error Charm creating Django Application: Error on Python side.Exit code:1