This web site is building a set of free materials, lectures, and assignments to help students learn the Django web development framework. You can take this course and receive a certificate at:
- Coursera: Django for Everybody Specialization
- edX: Django for Everybody XSeries Program
- FutureLearn: Django for Everybody Program
We use the free PythonAnywhere hosting environment to deploy and test our Django projects and applications. You can keep using this hosting environment to develop and deploy your Django applications after you complete the course.
This site uses Tsugi framework to embed a learning management system into this site and handle the autograders. If you are interested in collaborating to build these kinds of sites for yourself, please see the tsugi.org website.
This is how you install the Tsugi grading platform and the Django sample applications on a Windows machine using WSL (Windows Subsystem for Linux) and XAMPP.
-
Windows 10/11 with WSL2 (Ubuntu) installed
-
XAMPP installed on Windows (C:\xampp)
-
Git installed inside WSL.
-
Start XAMPP: Open XAMPP Control Panel and start Apache and MySQL.
-
Create Database: Go to http://localhost/phpmyadmin.
-
Create a new database named tsugi (UTF8MB4 Unicode).
4.Create User:
In the SQL tab, run:
SQL CREATE USER 'ltiuser'@'%' IDENTIFIED BY 'ltipassword'; GRANT ALL PRIVILEGES ON tsugi.* TO 'ltiuser'@'%'; FLUSH PRIVILEGES;
- Configure MySQL for WSL:
In XAMPP, click MySQL Config > my.ini.
-
Change bind-address=127.0.0.1 to bind-address=0.0.0.0.
-
Restart MySQL.
-
Navigate to Htdocs:
-
Inside Bash:
- cd /mnt/c/xampp/htdocs/
- mkdir dj4e && cd dj4e
- Clone Tsugi:
- git clone https://github.com/csev/dj4e.git .
- git clone https://github.com/csev/tsugi.git
- Configure Tsugi:
In the tsugi folder, copy config-dist.php to config.php.
- Edit config.php:
-
Set $wwwroot = 'http://127.0.0.1/dj4e/tsugi';
-
Set $pdo = 'mysql:host=127.0.0.1;port=3306;dbname=tsugi';
-
Set $adminpw = 'your_choice';
- Open http://127.0.0.1/dj4e/tsugi/admin in your browser.
Login and click Upgrade Database.
1.Clone Samples: Inside Bash:
- cd /mnt/c/xampp/htdocs/dj4e/
- git clone https://github.com/csev/dj4e-samples.git
- cd dj4e-samples
- Set up environment Inside Bash:
- sudo apt install python3-pip python3-venv libmysqlclient-dev pkg-config
- python3 -m venv venv
- source venv/bin/activate
- pip install -r requirements52.txt
-
Locate your Gateway IP: cat /etc/resolv.conf (e.g., 10.255.255.254)
-
Create dj4e-samples/settings_local.py and set the HOST to that Gateway IP:
Python DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'tsugi', 'USER': 'ltiuser', 'PASSWORD': 'ltipassword', 'HOST': '10.255.255.254', 'PORT': '3306', } } 5. Run Migrations & Start:
Inside Bash:
- python manage.py migrate
- python manage.py createsuperuser
- python manage.py runserver
-
404 Not Found: Ensure WSL Apache is stopped (sudo service apache2 stop) so XAMPP Apache can use Port 80
-
Connection Refused: Ensure the HOST in settings_local.py matches the Gateway IP from resolv.conf
-
Access Denied: Ensure the MySQL user in phpMyAdmin is granted access for '%' (any host)