Hi Pierre,
there was a similar question in the general chat today, at the moment we
have to resort to the django shell for this.
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.
For more info about how to use the django ORM (object relational mapper) to
perform queries, see Making Queries in the django documentation
<https://docs.djangoproject.com/en/3.1/topics/db/queries/>.
I hope this helps, try and let us know.
Best regards
*Federico Capoano*
OpenWISP OÜ
Harjumaa, Tallinn, Sepapaja tn 6, 15551
VAT: EE101989729
*openwisp.io* <http://openwisp.io>
On Mon, Mar 8, 2021 at 8:30 PM 'Pierre Untel' via OpenWISP <
[email protected]> wrote:
> Hi, I have a lot of already registered devices that I want to apply a new
> template to them, what's the most efficient way to do this?
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "OpenWISP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/openwisp/a7cb2744-0fbf-4f2f-8ba1-7cc4790ad1b4n%40googlegroups.com
> <https://groups.google.com/d/msgid/openwisp/a7cb2744-0fbf-4f2f-8ba1-7cc4790ad1b4n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups
"OpenWISP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web, visit
https://groups.google.com/d/msgid/openwisp/CAAGgX6JYbW%2BBaQhn3-pSaJzT2NbA0D3%2Bhrko5PZ5YBSrzJc46g%40mail.gmail.com.