Checking collection model attributes¶
It's not always easy to determine attribute values on Wagtail models representing collection (CIS) pages as often the attributes values are not directly used in the template. This following method is particularly for checking attribute values of collection model instances in the production environment.
Via the Django interactive shell¶
# Open the interactive shell in a local container with..
dj shell
# ** Or ** in the preprod/production environment with...
python3 manage.py shell
# Import the relevant model
from tate.art.artworks.models import ArtworkPage
# Use a unique attribute value, for example the 'acno' from the site page, to get the instance you're interested in
artwork = ArtworkPage.objects.all().filter(acno="AL00315")
# Assuming the qs holds what you're after - check the attribute value
artwork[0].map_spaces
Via a container running pgAdmin¶
Another method for local use only is to use the browser-based pgAdmin tool to inspect your local dev DB:
Start your db service as usual with fab start
Then run fab start --service pgadmin to start the 'pgadmin' service. This pulls an image from Dockerhub the first time you run it but will be very quick after that.
Then go to http://localhost:5050/browser/ and follow these steps:
- Sign in as user admin@admin.com with password root (as specified in the 'pgadmin' service block in docker-compose.yml)
- In the left-hand 'Browser' pane, right-click on the 'Servers' server group > Register > Server
- In the 'General' tab put a sensible name in the 'Name' field
- In the 'Connection' tab, set the 'Host name/address' field value to the 'name' of your docker wagtail DB container. This will probably be something like 'tate-wagtail-db', run
docker psto check - In the same 'Connection' tab, ensure the 'Port' field value is '5432' and 'Username' is set to 'tate'
- Then 'Save' and 'Close'
To see the tables click: Servers > Local (or whatever server name you used above) > Databases > tate > Schemas > Public > Tables
You can now right-click on any table and choose "View/Edit Data" > "First 100 Rows" (or "All Rows" if you want to see all the data). This will open a new tab showing all columns in the table.