the red penguin

2. Creating a new virtual environment

I used some of this video:

1. Create a new directory for the project

eg C:\Users\paulg.DESKTOP-AU8JD0H\Documents\django>

2. Go to CMD and navigate to the directory.

3. Create a virtual environment called env here

$ python -m venv env

4. To start this virtual environment type

$ env\Scripts\activate

We now get (env) before the prompt on the left.

5. We now need to install Django in the virtual environment.

$ pip install django

6. Now we can start the actual Django project. To do this we can start the project and give it a name. Type

$ django-admin startproject my_django_app

7. We can then open VSC and File/Open Folder to open this folder.

We can see a few .py files in the my_django_app directory and also outside this directory too.

8. We can run Django commands by going back to CMD, navigating to this folder and typing in a command to start the app.

$ cd my_django_app
$ python startapp hello

9. This adds a new directory. I need to go to settings for my_django_app and add this installed app. (We will do this in the next page).

10. To see Django working I need to go back to CMD and do this:

$ python runserver

There will be various messages but it will also say the server is running at . I can paste this into a browser tab:

I get a message saying “The install worked successfully! Congratulations!”

11. Creating a superuser

Next we stopped the server (CTRL+C) and did

$ python migrate
$ python createsuperuser

It then asked me to create a user name (paul), email and password.

12. I can now go to and enter my username and password.

We can now see user admin.

Wednesday 13 October 2021, 570 views

Leave a Reply

Your email address will not be published. Required fields are marked *