The following example shows how to add multiple templates, in case anyone needs it. Here's how I do it:
I cd into the OpenWISP installation dir and activate the python virtual environment where the OpenWISP dependencies are installed:
cd /opt/openwisp2
source env/bin/activate
./manage.py shell_plus
Then I type in the interactive shell (shell_plus comes from django-extensions and preloads the DB models of the packages that are installed in the django project):
template1 = Template.objects.get(id="<TEMPLATE_UUID_HERE>")
template2 = Template.objects.get(id="<TEMPLATE_UUID_HERE>")
for device in Device.objects.all():
device.config.templates.add(template1, template2)
The devices can be filtered as well with filter() in case you do not want to apply to all of them but only to a part.
I hope this helps, try and let us know.
Best regards
Federico CapoanoOpenWISP OÜ
Harjumaa, Tallinn, Sepapaja tn 6, 15551
VAT: EE101989729