Hello all,
I've had some troubles with default callables in FKs and tracked it down to one of my templates tags which returns a model class. I'm not sure if this is considered kosher or not so feel free comment on that too.
In my template I have a something like:
{{ my_project_lookup_class.classname.get_verbose_name }}
my_project_lookup_class.classname
will the return the django model class, and the template engine
apparently checks if the class is callable, then calls it which will try
to instanciate a new object with no arguments. In that specific case it fails because of missing default values but my intent was to call a classmethod anyway. I worked around it by using the do_not_call_in_templates flag on my models, because I'll never intend to call a constructor from a template anyway.
I've found a ticket corresponding to this issue.
https://code.djangoproject.com/ticket/16307and here's the discussion regarding the do_not_call_in_templates flag:
https://code.djangoproject.com/ticket/15791So my question is, would it make sense to make do_not_call_in_templates default to True for django's Model class ?
This would potentially break stuff if people used that trick to actually instantiate objects, I have no idea whether this is a common use case or not.