How to hide input value StringVar with asterisk on custom script

14 views
Skip to first unread message

Kittirat Thosathum

unread,
Jan 8, 2021, 10:24:49 AM1/8/21
to NetBox
Dear everyone,

How to hide input StringVar with asterisk on custom script? Due to  i would like to use custom script to do the same as login to device to run as below. Or I need to choose another type of input. Kindly advise me. Thank you

    device_ip = MultiChoiceVar(choices=CHOICES)
    username1 = StringVar(max_length=20, label="Username", required=True)
    password1 = StringVar(max_length=40, label="Password", required=True) 

Custom-script-hide-stringVar.JPG

Jeremy Stretch

unread,
Jan 8, 2021, 11:39:32 AM1/8/21
to Kittirat Thosathum, NetBox
Hi Kittirat,

You can specify a custom widget when defining the script variable, and use Django's built-in PasswordInput widget to mask the input value:

from django import forms

class MyScript(Script):
    password1 = StringVar(
        max_length=40,
        label="Password",
        required=True,
        widget=forms.PasswordInput
    )

Hope that helps!

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/36d5662d-e505-49cc-a2f3-e0a3f9ddf6b4n%40googlegroups.com.


--
Jeremy Stretch
Founder
NetVerity, LLC

Kittirat Thosathum

unread,
Jan 8, 2021, 11:55:41 AM1/8/21
to NetBox
Dear Jeremy,

Its work now. Thanks a lot! Cheeers.

ในวันที่ วันศุกร์ที่ 8 มกราคม ค.ศ. 2021 เวลา 23 นาฬิกา 39 นาที 32 วินาที UTC+7 jer...@netverity.dev เขียนว่า:
Reply all
Reply to author
Forward
0 new messages