Web App for the Imperative DL Study https://fathomless-inlet-57767.herokuapp.com
mysqlclient
is installed (either via Brew or other methods) https://pypi.org/project/mysqlclient/export DYLD_LIBRARY_PATH="/usr/local/mysql/lib/"
pip install psycopg2-binary
1) Ensure all pre-requisites above are met.
2) Install dependencies: pip install -r requirements.txt
3) Run the app: python manage.py runserver
4) Navigate to: localhost:8000
to view the app.
5) To create an admin account, python manage.py createsuperuser
and follow instructions to provide account credentials.
localhost:8000
page throws an access error, consider adding localhost
to ALLOWED_HOSTS
in the settings.py
file.STATIC_ROOT
see: https://github.com/OpenToAllCTF/OTA-University/issues/9 suggestion to change STATIC_ROOT
assignment to just /static/
1) Create a database and configure the DATABASES
dictionary in the settings.py
file to connect to it.
2) Run migrations to create the schema using the commands:
python manage.py makemigrations
python manage.py migrate
3) 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).
1) To dump initial data from a specific database into a fixture (data.json for example), use the dumpdata
command:
python manage.py dumpdata --exclude=auth.permission --exclude=contenttypes > ponder/fixtures/data.json
2) Fixtures can be JSON, XML, or YAML files. For YAML fixtures, pip install PyYAML
.
3) To load to the database, run data migrations using the loaddata
command:
python manage.py loaddata data.json
4) Then configure the group permissions from the Admin page.
The fixture can be used to load data to a local database.
1) First connect to a local database, then configure the DATABASES
dictionary in settings.py
as 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',
}
}
2) Run migrations and use the command: python manage.py loaddata data.json
3) 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 test
Tests 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.
Dockerfile
docker-compose.yml
manage.py
mysite
ponder
requirements.txt
.
├── 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
├── models.py
├── static
├── tables.py
├── templates
├── tests.py
├── urls.py
└── views.py
To build the Docker image:
docker-compose up
ALLOWED_HOSTS
in the settings.py
file.CTRL-C
in the same shell or run docker-compose down
from another shell.The app has a complex relationship between different kinds of users. The roles are described in our wiki.
Field | Value |
---|---|
Username | admin |
Password | umjawaRZ7GY5C7Q |
You can use this to register for accounts in the web app that is deployed on Heroku.