Skip to content

Add "Config Templates" during creating device in script. #15416

Answered by candlerb
LuaLua10 asked this question in Help Wanted!
Discussion options

You must be logged in to vote

In the source code, class Device is here. It mixes in RenderConfigMixin from here.

    config_template = models.ForeignKey(
        to='extras.ConfigTemplate',
        on_delete=models.PROTECT,
        related_name='%(class)ss',
        blank=True,
        null=True
    )

Therefore you should be able to set something like this:

device = Device(
    ...
    config_template = data["device_config_template"],
)

although it needs to be an ObjectVar not a MultiObjectVar (since it points to a single ConfigTemplate, not a set of them)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@LuaLua10
Comment options

Answer selected by LuaLua10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants