Web App for the Imperative DL Study https://tranquil-anchorage-16644-bbe77c4a9151.herokuapp.com/
Python 3.13.1
Pip: 3.13
Django: 5.1.4
- Ensure Django is set up: https://docs.djangoproject.com/en/5.1/topics/install/
- For MySQL databases, ensure mysql is set up: https://dev.mysql.com/doc/refman/8.0/en/installing.html
- Additionally, also ensure
mysqlclientis installed (either via Brew or other methods) https://pypi.org/project/mysqlclient/ - Ensure the below PATH is exported in your environment
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib/"
- Additionally, also ensure
- For PostgreSQL databases,
pip install psycopg2-binary
- Ensure all pre-requisites above are met.
- Install dependencies:
pip install -r requirements.txt - Ensure database is set up correctly (both remote and local as needed), see instructions below.
- Run the app:
python manage.py runserver5) To enable debugging mode, export env variable:export DJANGO_DEBUG="True" - Navigate to:
localhost:8000to view the app. - To create an admin account,
python manage.py createsuperuserand follow instructions to provide account credentials.
- Debug: If the above
localhost:8000page throws an access error, consider addinglocalhosttoALLOWED_HOSTSin thesettings.pyfile. - Debug: If you run into error regarding
STATIC_ROOTsee: OpenToAllCTF/OTA-University#9 suggestion to changeSTATIC_ROOTassignment to just/static/
- Create a database and configure the
DATABASESdictionary in thesettings.pyfile to connect to it. 2) See steps below to set up a local database if needed. - Run migrations to create the schema using the commands:
python manage.py makemigrationspython manage.py migrate- Use SQL commands to populate the tables with data.
The database can be populated with initial data by first dumping the data into a fixture (fixtures can also be written manually).
- To dump initial data from a specific database into a fixture (data.json for example), use the
dumpdatacommand:
python manage.py dumpdata --exclude=auth.permission --exclude=contenttypes > ponder/fixtures/data.json- Fixtures can be JSON, XML, or YAML files. For YAML fixtures,
pip install PyYAML. - To load to the database, run data migrations using the
loaddatacommand:
python manage.py loaddata data.json- Then configure the group permissions from the Admin page.
The fixture can be used to load data to a local database.
- First connect to a local database, then configure the
DATABASESdictionary insettings.pyas follows:
DATABASES = {
'default': {
'ENGINE': '<YOUR_BUILT_IN_DB_BACKEND>',
'NAME': '<YOUR_LOCAL_DB_NAME>',
'USER': '<YOUR_LOCAL_DB_USER>',
'PASSWORD': '<YOUR_LOCAL_DB_USER_PASSWORD>',
'HOST': 'localhost',
}
}- Run migrations and use the command:
python manage.py loaddata data.json - Note that running the loaddata command will reload the data from the fixture into the database, removing any changes that you might have made to the database tables.
Use this command to run the tests in tests.py:
python manage.py testTests that require a database will run on a separate test database. Make sure that the USER in settings.py is granted privileges to create a database.
- Docker Compose should be installed to build the app's container image.
- On Windows or Mac systems, install Docker Desktop. It includes Docker Engine, Docker CLI client and Docker Compose.
- For information on how to install Docker Compose on Linux systems, the instructions are listed in this page: https://docs.docker.com/compose/install/
- The Docker directory currently includes only two files:
Dockerfiledocker-compose.yml
- Include the following to the above directory:
manage.pymysiteponderrequirements.txt
- This should be the final Docker directory tree:
.
├── Dockerfile
├── docker-compose.yml
├── manage.py
├── mysite
│ ├── __init__.py
│ ├── __pycache__
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── ponder
├── __init__.py
├── __pycache__
├── admin.py
├── apps.py
├── fixtures
├── forms.py
├── migrations
├── test
├── models.py
├── static
├── tables.py
├── templates
├── urls.py
└── views.py To build the Docker image:
- In the terminal, go to the top level directory and run the command:
docker-compose up - This will build the image on Docker Desktop with multiple containers (web and db containers). Go to http://localhost:8000/ in your browser to view the running app.
- You need to add localhost to
ALLOWED_HOSTSin thesettings.pyfile. - To shutdown the services, type
CTRL-Cin the same shell or rundocker-compose downfrom another shell.
The app has a complex relationship between different kinds of users. The roles are described in our wiki.