﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31046	Support callable values in through_defaults.	Baptiste Mispelon	Baptiste Mispelon	"Ticket #9475 gave us `through_defaults` but unlike the `defaults` argument of `get_or_create` [1] or the `default` argument of any model field, it doesn't allow callable values.

Callable values are passed through without being evaluated so the exact behavior depends on the fields. With a `CharField` for example, the `repr()` of the function will be saved to the database which is most likely not what the user is expecting.

I took a look at the original ticket and pull request but couldn't find a mention of this use-case (ctrl+F for the word ""callable"") so it seems that it was an oversight rather than a deliberate design decision.

Code-wise, fixing this is actually pretty straightforward and doesn't seem to cause any regression (see attached pull request).

[1] https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.get_or_create"	New feature	closed	Database layer (models, ORM)	dev	Normal	fixed			Accepted	1	0	0	0	0	0
