﻿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
11527	Documentation and testing for F() assignment to model attributes	Zachary Voase	Zachary Voase	"Add explicit documentation and regression tests for the use of `django.db.models.F()`-expressions when assigning directly to attributes on model instances (as opposed to just using them in batch `update()` calls).

The pattern goes something like this:

{{{
>>> from django.db.models import F
>>> from myapp.models import MyModel
>>> obj = MyModel(count=1)
>>> obj.save()
>>> obj.count
1
>>> obj.count = F('count') + 2
>>> obj.save()
>>> obj = MyModel.objects.get(pk=obj.pk) # Necessary to reload here, as the `count` attribute will still be an Expression object.
>>> obj.count
3
}}}

This should ''not'' work on records which do not already exist, since `F()`-expressions only work in `UPDATE` queries.

It's also important for this to work with any pre-save and post-save signal handlers defined in any of the django.contrib apps."		closed	Database layer (models, ORM)	dev		fixed			Accepted	1	0	0	0	0	0
