This is a Django application based on a YouTube Video presented by Dennis Ivy. Please check out his channel on YouTube. Also, you should take the time to read this article on class based views in django. The article has many great links to django resources.
This was a quick and fun django project and taught me a lot about class based views in django.
-
Create a virtual environment with the command:
python3 -m venv todo_env
-
Create a directory named todo_list.
-
Start the virtual environment created in #1 using the command:
- Mac
source todo_env/bin/activate
- Windows
todo_env\Scripts\activate.bat
-
Use pip to install the Django module:
pip install django
-
Run django-admin to start the project with the command:
django-admin startproject todo_list
-
CD into the todo_list directory. You should see a manage.py file in the folder. You can run the following command to start the server:
python manage.py runserver
-
You should get a message like this:
Django version 3.1.7, using settings 'Django_Project.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
-
You can launch a web browser and go to the above URL and you should see a default django landing page.
Once the server is functional you can then start your application. For this project the command used is:
python manage.py startapp base
This will create a new folder named base in the django_project directory and populate it with the necessary files to start coding your application.
To access the Admin page feature of Django you have to run the initial migration to initialize the auth user database. The commands used are:
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
When you run createsuperuser you will be prompted to enter a username and password for the default admin user. You can then run the server and login to the admin page at http://127.0.0.1:8000/admin.