I was asked this on an interview presumably to see if I understood the separation between the Template layer and the Model layer.
My understanding is that template variables are essentially:
- A static copy of the instance (such that all the properties can be accessed)
- An instance that has all of the method with arguments "hidden" (such that they can't be called, but methods without arguments can be called )
Therefore, if you had a model with only methods with no arguments and passed an instance into a template could you say that it was a static copy of the instance? Is this even a correct way to think about template variables?
UPDATE:
Is the template (view) layer able to update models (e.g. from a custom context processor)? If no, then how is this prevented by the Django framework if it's not making copies of the model instance? If yes, then wouldn't this be a major deviation from typical web framework MVC design where data only flows in one direction from Model to View?