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.
--
Ticket URL: <https://code.djangoproject.com/ticket/25340>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_docs: => 0
* resolution: => duplicate
* needs_tests: => 0
* needs_better_patch: => 0
Comment:
Duplicate of #24509.
--
Ticket URL: <https://code.djangoproject.com/ticket/25340#comment:1>