[07:16] <rvba> jtv1: it's in /etc/maas/templates/deployment-user-data/maas_configure_interfaces.py
[07:20] <jtv1> rvba: great, thanks.  That's the expected location.
[07:21] <jtv1> I just mis-typed it earlier.
[07:21] <rvba> Ah, okay.
[11:29] <jtv> rvba: can I impose on your Django knowledge?
[11:29] <jtv> I'm trying to set a computed default value for a form field.
[11:30] <jtv> When I clean the field in the form, it's always present and its cleaned_data value is never None.
[11:30] <jtv> The django docs say that setting an "initial" value is not the way to do this, but they don't say what is.
[11:31] <jtv> (Even setting a callable default on the model wouldn't do the trick, because the default needs to refer to the Node object itself)
[11:32] <rvba> jtv: I don't understand why you're saying that the field is always present and that its cleaned_data value is never None.  Is that a result of something you've done?
[11:34] <rvba> jtv: why can't you set your default value in the form's __init__?
[11:34] <jtv> Could be.  When my clean_<field> method (on the form) looks for self.cleaned_data.get(<field>) it never gets None back.
[11:34] <jtv> Set it in the form's __init__?  Do I have the instance at that point, when the form is creating a new object?
[11:35] <rvba> No, unless you create it yourself manually, then *update* it when save() is called.
[11:35] <rvba> So, you want the initial value to depend on a non-yet created object?
[11:35] <rvba> I don't understand.
[11:36] <jtv> This is NodeForm; all I really need is its NodeGroup.
[11:36] <jtv> If I can get that, I can get the default value.
[11:37] <rvba> Then presumably you want to pass the nodegroup to the form's __init__ and derive the default value from it.
[11:38] <rvba> Same as what NodeGroupDefineForm does with 'status'.
[11:41] <jtv> rvba: so... overriding save() looks like the only way to set a computed default with access to the object's properties..?
[11:41] <rvba> jtv: yes, save() is where the object is created by the form.
[11:42] <rvba> jtv: but surely the data you need (the nodegroup) is part of the data sent to the form?
[11:43] <jtv> Probably, yes.  I'm more worried at this stage about how I'll know whether a value was submitted for my field.
[11:46] <rvba> jtv: if no value was submitted for the field, cleaned_data should be set to the default value.
[11:46] <rvba> cleaned_data.get(field_name) that is
[11:46] <jtv> The default _model_ value?
[11:47] <jtv> Well stupid question I guess,
[11:47] <jtv> since there doesn't seem to be a default form value.
[11:48] <jtv> I guess I'd have to make the model-level field default to None, but disallow nulls?
[11:49] <rvba> Yes, I assume the default model value is there when the form gets validated.
[11:50] <rvba> I don't think you need to make the model-level field default to None.
[11:53] <jtv> Well it's a boolean field that can't be null, and I need a way to know whether a value was provided to the form...
[11:54] <jtv> I get the impression that the model is the only level where I can provide a default.
[11:54] <jtv> (Unless we count "initial" which the docs say won't do this.)
[11:54]  * jtv eats for a bit
[11:56]  * rvba → lunch
[12:42] <jtv> Arrrrrgh!  My problem was in factory.make_NodeGroup accepting my new field but not passing it on!
[12:44] <jtv> That's why my test failed: the default was always False, even if I explicitly set it to True.
[12:44] <jtv> Question now is: at what point in all my experiments did the test start failing for that reason?
[13:07] <jtv> Urgh.  That's enough for tonight.  Have a good weekend everyone.