Run Django 5.0 on a Chromebook
I own an HP Chromebook and use it for my private side projects. I wanted to try Django 5.0 to learn something new for a new project idea. I also do not want to rely too much on Google Firebase, which I use for a different project. Finally, I like programming in Python but have not done it for a while.
So, I thought it would be straightforward, but it was not too simple...
First I realized that my default Python version is too old to run Django 5.0
$ python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
According to https://docs.djangoproject.com/en/5.0/faq/install/#faq-python-version-support, I need at least Python 3.10.
Since it was not possible to just apt install
Python3.12, I had to compile it from the source code.
I googled a bit and then followed Option 2 from https://ubuntuhandbook.org/index.php/2023/05/install-python-3-12-ubuntu/ without setting Python3.12 as default because I do not want to run in potential side effects doing so.
Everything ran smoothly, so I installed a virtual environment with Python3.12 and installed Django 5.0.
$ python3.12 -m venv venv
$ . venv/bin/activate
$ (venv) pip install Django==5.0.1
Then I created a new Django app and wanted to run it, but it failed because it could not load '_sqlite3'. Uff, what a f"§$...
Seems like I always have setups that need special treatment. Luckily I am not the only one with such issues as I found out at https://waylonwalker.com/pyenv-no-sqlite3/.
The trick is to install libsqlite3-dev
before installing Python.
$ sudo apt install libsqlite3-dev
Ok, so I started over again. It is necessary to start the complete build process starting with the configure
step because during configuration, sqlite3
installation is recognized.
Finally, I deleted the virtual environment and created it from scratch. Et voilà, finally it works.
$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
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.
January 15, 2024 - 05:18:00
Django version 5.0.1, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[15/Jan/2024 05:18:09] "GET / HTTP/1.1" 200 10629
Not Found: /favicon.ico
[15/Jan/2024 05:18:09] "GET /favicon.ico HTTP/1.1" 404 2110