ReportBro album application for Django web framework. This is a fully working demo app to showcase ReportBro and how you can integrate it in your Django application.
The application is a simple web app and allows to manage a list of music albums. ReportBro Designer is included so you can modify a template which is used when you print a pdf of all your albums.
The Demo App is also avaiable for the Flask and web2py web frameworks. See Album App for Flask and Album App for web2py respectively.
All Instructions in this file are for a Linux/Mac shell but the commands are easy to adapt for Windows. If a command is different for Windows then it will be shown below. Commands which can be done in Windows Explorer (e.g. copy file, create directory) are not explicitly listed for Windows.
Clone the git repository and change into the created directory:
$ git clone https://github.com/jobsta/albumapp-django.git
$ cd albumapp-django
Create a virtual environment called env:
$ python3 -m venv env
Activate the virtual environment:
$ . env/bin/activate
On Windows the virtual environment is activated this way instead:
$ env\Scripts\activate
Once the virtual environment is activated you should see the environment name prepended to the shell prompt.
Install all required dependencies:
$ pip install django reportbro-lib
- Activate the virtual environment (if not already active):
$ . env/bin/activate
- Create a database (albumapp.sqlite) by creating migration scripts and executing them:
$ python manage.py makemigrations albums
$ python manage.py migrate
- Compile all translation files so the labels can be used in the application (generates django.mo next to django.po):
$ python manage.py compilemessages
Activate the virtual environment (if not already active):
$ . env/bin/activate
Start the Django webserver:
$ python manage.py runserver
Now your application is running and can be accessed here: http://127.0.0.1:8000/albums/
- Open the cloned albumapp-django directory
- Add virtual env to project:
- Select File -> Settings
- Project: albumapp-django -> Project interpreter
- click Settings-Icon and select "Add Local" option, select the recently created virtual env
sqlite is used as database to store the application data (albums), report templates and report previews used by ReportBro Designer.
To initially create the db with its tables the following steps are necessary:
Activate the virtual environment (if not already active):
$ . env/bin/activate
Create database migrations:
$ python manage.py makemigrations albums
Execute migration scripts:
$ python manage.py migrate
Activate virtual environment (if not already active):
$ . env/bin/activate
Run over the entire source tree of the current directory and pull out all strings marked for translation. It creates (or updates) the django.po message file:
$ python manage.py makemessages
Compile all translation files so labels can be used in the application (generates django.mo next to django.po):
$ python manage.py compilemessages --ignore env
The PEP 8 (Python Enhancement Proposal) standard is used which is the de-facto code style guide for Python. An easy-to-read version of PEP 8 can be found at https://pep8.org/
Basically follow the instructions at https://help.pythonanywhere.com/pages/DeployExistingDjangoProject
Upload code to PythonAnywhere:
$ git clone https://github.com/jobsta/albumapp-django.git
In django_demoapp/settings.py you have to enter your url in ALLOWED_HOSTS, e.g.
ALLOWED_HOSTS = ['myuser.pythonanywhere.com']
and set STATIC_ROOT accordingly:
STATIC_ROOT = '/home/myuser/albumapp-django/albums/static'
On the PythonAnywhere 'Web' Page you have to make sure everything is configured as described (Source code and working dir, wsgi file, virtualenv). The wsgi file looks something like this:
import os
import sys
path = '/home/myuser/albumapp-django'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'django_demoapp.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
For 'Static files' you enter the following mapping:
URL: /static/
Directory: /home/myuser/albumapp-django/albums/static
Don't forget to perform the necessary installation steps for the django albumapp itself, i.e. DB migrations and compile translation messages (see above).
Reload the application and run!