﻿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
25340	Allow use of expressions in Model.objects.create()	Joey Wilhelm	nobody	"I have a case where I need to assign a field value from the return of a database function, but I do not want to set a default for the field.

Currently, the following will work:

{{{
#!python
from django.db.models.expressions import Func

from .models import MyModel

instance = MyModel.objects.create(
    ...
)
instance.code = Func(*my_args, function='generate_unique_code')
instance.save(update_fields=['code'])
}}}

However, the following:
{{{
#!python
from django.db.models.expressions import Func

from .models import MyModel

instance = MyModel.objects.create(
    ...,
    code=Func(*my_args, function='generate_unique_code')
)
}}}
produces `TypeError: int() argument must be a string, a bytes-like object or a number, not 'Func'`

I would expect that these two methods for assigning the value should behave similarly."	New feature	closed	Database layer (models, ORM)	1.8	Normal	duplicate			Unreviewed	0	0	0	0	0	0
