Installation

Note

If your instance runs on the hosted Juntagrico PaaS this installation is done for you. Continue with the basic setup.

Prerequisites

Make sure python is installed on your system.

Create new Django app using Cookiecutter

You may use the cookiecutter template to create a fresh django app. This will create a django project and app, with all the required settings and urls set up.

$ pip install cookiecutter
$ cookiecutter gh:juntagrico/juntagrico-science-django-cookiecutter

Check out the Cookiecutter documentation on how to install cookiecutter on your system.

Then install the requirements with pip:

$ pip install -r requirements.txt

The default setup will use a local SQLite database and fails to send out emails. For production you will need to configure the database and email connection using environment variables or directly in the settings.py. Refer to the generated settings.py and the django documentation.

You are now ready to continue with Initial Django setup.

Alternative: Install in an existing Django app

If instead you already have a django project you can add juntagrico as an app to it.

Install juntagrico, e.g. via pip:

$ pip install juntagrico

Update Django Settings

Update your projects settings.py.

Refer to settings/minimal.py for the minimal settings required to run Juntagrico.

For sending out emails, the corresponding django settings need to be configured properly. Read the django documentation for more details.

In the demo app you can find a more complete set of settings, suitable for the production environment.

Additional settings will be explained in the basic setup section.

Hook URLs in URLconf

Include these urls to your urls.py:

# urls.py
from django.urls import path, include
from django.contrib import admin

urlpatterns = [
    path('admin/', admin.site.urls),
    path('impersonate/', include('impersonate.urls')),
    path('', include('juntagrico.urls')),
]

Initial Django setup

Use the django commands to set up the database:

$ python -m manage migrate

In production (DEBUG=False) the static files must be collected:

$ python -m manage collectstatic

Create a superuser with member to login into your instance:

$ python -m manage createadmin

Create Test Data (optional)

If you want to test juntagrico, these commands will populate your new instance with some example data. Do not do this in production!

Simple example data

$ python -m manage generate_testdata

More complex example data

$ python -m manage generate_testdata_advanced

Run the Server

You should now be able to start the django server and open the instance in the browser e.g.:

$ python -m manage runserver