Skip to content

How to add new field choices to Signbank

Wessel Stoop edited this page Feb 13, 2015 · 5 revisions

Introduction

For various fields in Signbank (where field is the property of a particular gloss), there is a limited set of options. For example, for the field 'Handedness', we can choose from:

  • 1
  • 2
  • 2a
  • 2s
  • X

This article is about how you can extend lists of choices like this.

Unfortunately, this can not be done in some intuitive admin control panel only. This is because Django options were not designed to be dynamic; in retrospect, we should have used something else for it. However, because this would lead to quite radical and time-consuming changes in both the database and code of the website, I decided it would be better to do it in this clumsy way. No coding knowledge needed.

The steps

Step 1: Go the right location.

Go the control panel > Field choices. Here you will see an overview of all Signbank's choices, grouped together in Choice Lists.

Step 2: Pick your machine value.

Find the name of the list you want to extend (something like 'Handedness' or 'RelatArtic'). All choices have a number between brackets. Find the highest number, and add 1 to it. This is the 'machine value' (the value saved in the database) of your new choice.

Step 3: Add the choice.

Now, add a new choice, using the machine value you just picked, and then verify that is has been added to your list. The important part is now done.

Step 4: Erase the cache.

Unfortunately, our webserver Apache tries to cache as much of Signbank as possible, so it can deliver its webpages quickly. This means that Apache will remember the old choice lists, and won't show the new one until we tell it something has changed. We can do this by going to this url:

http://signbank.science.ru.nl/reload_signbank/

In case you're interested, what this does under the hood is:

  • Change the 'Last modified' date of wsgi.py, which is the script that tells Apache what Django wants to show. If this date changes, Apache assumes it must erase its cache.
  • It makes two empty requests via Javascript. This is because, after a cleared cache, the first two requests to Apache/Django always fail. By going to this url you do the two failing requests without having to worry about it, or see the scary error messages.