Interactions with GeoNode from the command line

“GeoNode has additional python commands which is only accessible on the host where GeoNode is installed”

GeoNode provides command-line options for doing various administrative tasks in GeoNode. These commands can be run by an administrator with programming knowledge. These commands also help in the automatic ingestion of the large raster into GeoNode. The management commands are an extension of the admin interface as they allow user to do additional tasks that are not available in the admin interface.

In this module, we explore the management interface from the command line.

You try:

Goal: To explore the some management commands

Docker or Kubernetes

  • Navigate to the server where the GeoNode is installed.
  • Locate the running django container and exec the container.
  • Run the following command

    python manage.py --help

  • Download the raster using the command line tool like get or curl

    mkdir raster; wget https://github.com/kartoza/docker-mapserver/blob/master/map/E020N40.tif - O raster/E020N40.tif

  • Inspect the command to use to ingest the raster into GeoNode

    python manage.py importlayers -n "East Africa" -v 3 raster

  • Inspect the layer in GeoNode to see if has been published.

Virtual Env

  • Change directory to where the source code for GeoNode is installed
  • Activate the virtual env.
  • Run the management command as mentioned in the docker section

Check your results

When you are in the Django container you should be able to run a command without getting an error message. Execute python manage.py createsuperuser to ensure that you set up a master account on GeoNode.

Name Expectation

GeoNode Install method

Rancher, Docker-compose, Ansible, Virtual Env

Docker container lookup

docker ps -a

Django Container Log in (Docker)

docker exec it django bash

Python Management Commands lookup

python manage.py --help

More about management commands

GeoNode is built with Django and Python with a backend of either Geoserver or QGIS server and a PostgreSQL database backend. Django has an admin interface that allows users to manipulate all the data and other related components relating to permissions for layers. The management command provides a set of management tools that extend the functionality of the Django admin.

Example of management commands on the command-line. Assume all commands start with python manage.py $name of the command. Where the $name of command could be

  • createsuperuser
  • importlayers
  • updatelayers
  • sync_geonode_maps
  • set_all_layers_metadata

For a full list of all the management commands execute python manage.py –help and choose each individual command to understand how it can be executed for example python manage.py importlayers –help

Probably the two main reasons you would need the management commands are:

  • to upload and publish very large layers that time out through the web interface
  • to publish layers that are available in the backend but not yet in GeoNode

Check your knowledge:

  1. What components make up GeoNode :

    1. QGIS Desktop,Django and Celery
    2. GeoServer or QGIS Server, Django,PostgreSQL
    3. Django,python3,QGIS Desktop
  2. Why would you want to use the command line management commands vs admin interface accessible on the browser:

    1. It does not make sense, the browser is much more friendly
    2. The command-line should not be used because it is complex
    3. The command-line allows a user to do more tasks in an automated way which the admin interface will not be able to achieve
    4. The admin interface is simpler and easy to use and has more commands
  3. How would you use the command line management tools:

    1. Yes, Only if you have installed management software like rancher
    2. It is impossible, you need server access