First, prepare your development environment by installing pip, virtualenv, and postgresql-server-dev-X.Y.
-```
-$ sudo apt install python-pip postgresql-server-dev-14
-
-$ pip install virtualenv
+```bash
+sudo apt install python-pip postgresql-server-dev-14
```
Next, configure your local environment with virtualenv and install local dependencies.
+```bash
+python3 -m venv env
+source env/bin/activate
+pip install -r dev_requirements.txt
```
-$ virtualenv env
-$ source env/bin/activate
-$ pip install -r requirements.txt
-```
-
-Now prepare the application to run locally.
-Configure the app to match your local installation by creating a
-`local_settings.py` with the following content in the `pgcommitfest` directory.
-Change the values for the database connection adequately.
+Create a database for the application:
-```
-# Enable more debugging information
-DEBUG = True
-# Prevent logging to try to send emails to postgresql.org admins.
-# Use the default Django logging settings instead.
-LOGGING = None
-
-DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.postgresql_psycopg2',
- 'NAME': 'pgcommitfest',
- 'USER': 'postgres',
- 'PASSWORD': 'postgres',
- 'HOST': '0.0.0.0',
- }
-}
-
-# Disables the PostgreSQL.ORG authentication.
-# Use the default built-in Django authentication module.
-AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend']
+```bash
+createdb pgcommitfest
```
-Provided that you created a database matching the above settings, you can
-now create the required tables. Note that a password must be provided.
+Create a local settings file (feel free to edit it):
-```
-$ python manage.py migrate
+```bash
+cp pgcommitfest/local_settings_example.py pgcommitfest/local_settings.py
```
-You'll need either a database dump of the actual server's data or else to create a superuser:
+Now you can now create the required tables. Note that a password might need to
+be provided.
-```
-$ python manage.py createsuperuser
+```bash
+./manage.py migrate
```
-Finally, you're ready to start the application:
+You'll need either a database dump of the actual server's data or else to create a superuser:
-```
-$ python manage.py runserver
+```bash
+./manage.py createsuperuser
```
-To authenticate you'll first have to remove the customized login template.
-Remember not to commit this modification.
+Finally, you're ready to start the application:
-```
-$ find . -type f -name login.html
-$ rm -f global_templates/admin/login.html
+```bash
+./run_dev.py
```
-Then open http://localhost:8000/admin to log in. Once redirected to the Django
+Then open http://localhost:8007/admin to log in. Once redirected to the Django
admin interface, go back to the main interface. You're now logged in.
--- /dev/null
+# Enable more debugging information
+DEBUG = True
+# Prevent logging to try to send emails to postgresql.org admins.
+# Use the default Django logging settings instead.
+LOGGING = None
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
+ 'NAME': 'pgcommitfest',
+ 'USER': 'postgres',
+ 'PASSWORD': 'postgres',
+ 'HOST': '0.0.0.0',
+ }
+}
+
+# Disables the PostgreSQL.ORG authentication.
+# Use the default built-in Django authentication module.
+AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend']
--- /dev/null
+#!/usr/bin/env python3
+"""Run uWSGI with Django static files mapping.
+
+The reason we don't hardcode the path to the static admin directory in the
+uwsgi_dev.ini file is because the path contains the python version, something
+like:
+
+env/lib/python3.12/site-packages/django/...
+
+Requiring everyone to use the same python version is not practical, so instead
+we have this tiny script that will find the path to the Django admin static
+files and run uWSGI with the correct path.
+"""
+from importlib.machinery import PathFinder
+import subprocess
+import sys
+
+django_path = PathFinder().find_spec("django").submodule_search_locations[0]
+
+django_admin_path = django_path + "/contrib/admin/static/admin"
+
+if len(sys.argv) > 1:
+ ini_file = sys.argv[1]
+else:
+ ini_file = "uwsgi_dev.ini"
+
+subprocess.run(
+ [
+ "uwsgi",
+ "--static-map",
+ f"/media/admin={django_path}/contrib/admin/static/admin",
+ ini_file,
+ ]
+)