My issue is with the commented line :
How to pass the varables (inv_app_fs and self.inventaire_name), concataned to the string : “.ok” (dot is important, as you can guess).
Should I wrap variables into ‘{’, or ‘{{’, or ?..
A model field can define a default, but the values are assigned to the instance of that model.
It’s actually not any different than any other field in that regard. You can assign a value to the inv_file_path field the same way you assign a value to the inventaire_name field. They really aren’t very different. (At the database layer, it’s just another CharField.)
Thanks for your answer.
My issue is not “how to assign a value” to the attribute, but how should I use this value in the path=argument ?
It’s a syntax issue for :
path="inv_app_fs/{ self.inventaire_name }.ok"
Should I use brackets around variable names, or double, or nothing ? For now, in tests I did with shell commands, it created directory named inv_app_fs (or even {{ inv_app_fs }}), but not /inventaires_ansible.
Yes, I’m already following the official tutorial, adapting it to my needs. I guess this is a basic point, but I found the answer anywhere.
Could you, for example, give me an example of working line for :
If it’s dynamic, it’s done on the instance of the model.
Django models are not typical Python classes. They’re heavily meta-class driven such that the Model definition ends up creating a class for the model. The field definitions do not directly create a “field value” attribute.
You need to not think of Models the same way you would think of any other type of Python class. For example, one of the things you should never do is override the __init__ method of a model. There are other hooks available for doing the types of things you might think of doing there.