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