-
Notifications
You must be signed in to change notification settings - Fork 1
Backend: Quick Start
Before starting you have to create a .env file in bittan/backend/bittan/bittan/.env
and write
APPLICATION_URL=<URL> #E.g https://XXX.serveo.net/
Where url is a url from which you globally can access your app. Read the Swish section if you do not know how to get a globally accessible url. If you do not need swish to work, you can write anything in place of and just let swish not be able to reach you.
To start the backend locally, you must have Docker installed. Run the following command in /backend/
:
docker compose up --build
You can access a terminal in the server container, for example by running:
docker exec -it bittan_server bash
In this terminal, you can fill the database with mock data by running:
./create_mockdata.sh
followed by 1
. NOTE: Depending on Git config, Windows users may need to change CRLF to LF in the files create_mockdata.sh
and scripts/create_mockdata.py
.
At this point, you should be able to open your favorite browser and go to localhost:8000/admin
and login to the admin page with username "admin" and password "admin"!
When migrating or running ./create_mockdata.sh
, you may see an error message similar to `It is impossible to add a non-nullable field to without specifying a default. If this is on your local machine where you don't care about the database, some or all of the following actions can be taken to fix this:
- Delete
/backend/bittan/bittan/migrations
- Delete the postgres_data by deleting its volume using the following commands:
docker compose stop postgres # Stops the container (only required if container is running)
docker compose rm postgres # Removes the container (only required if container is running)
docker volume rm backend_postgres_data # Removes the volume
docker compose up -d postgres # Restarts the container
- Delete and rebuild the container
To be able to get callback responses from Swish, you app has to be accessible from "the internet". To do this you can use a service such as Serveo or Localrun. A list of services like these can be found here. These allows you to get a https link to your django application. We recomend using Serveo since it's free and does not change it's address so often. Run the command below to tunnel your django application. To run Serve you only need to have ssh installed. On your host machine (not in the docker container) run:
ssh -R 80:localhost:8000 serveo.net
# Or if you would like a particular subdomain
ssh -R <subdomain>:80:localhost:8000 serveo.net