Shai and Ayeric, thank you so much for the feedback. The PR did indeed 
snowball into a much bigger one that I had initially planned. I agree with 
all points except,

> - controlling this behavior in the query rather than in the field 
definition — this avoids the awkward “ignore what the field says” query 
parameter 

The main reason this PR exists is to let the fields decide if they should 
be updated/refreshed or not. If we don't define this behavior on the 
fields, then the feature will never work with 3rd party apps as developers 
will have to consciously remember to use some method on query API. For 
example, we could add a pguuid field to postgresql package that sets 
behaves like a normal uuid field but calculates the value using 
postgresql's uuid function. This would only work if the we define the 
preference on the field itself and the query API implicitly respects that.

The minimum public API we would need to make this happen is to add an 
option to the Field class, something like,

> id = models.IntegerField(db_computed=True)

`db_computed` would make django do 2 things, it would implicitly ignore the 
field when updating and inserting and it would auto fetch the value from 
the DB after every insert/update on supported backends. That's it. 
Everything else was added to make this a bit flexible, like to make a field 
behave like this only or INSERT or on UPDATE but I think even having just 
one param that does it for both insert and update would be awesome!

--
Owais

On Monday, February 1, 2016 at 2:03:26 PM UTC+5:30, Aymeric Augustin wrote:
>
> > On 31 janv. 2016, at 22:55, Shai Berger <[email protected] 
> <javascript:>> wrote: 
> > 
> > Your message seems to be confusing the queryset API with the 
> model-instance 
> > API. 
>
> Oops :-( 
>
> Anyway, it seems that we agree on: 
>
> - controlling this behavior in the query rather than in the field 
> definition — this avoids the awkward “ignore what the field says” query 
> parameter 
> - trying not to provide separate APIs for insert and update behavior 
> - improving the save(update_fields=…) API to support inserts as well as 
> updates 
>
> -- 
> Aymeric. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/2ac56d4e-9259-4fa6-985b-4311686662b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to