Re: [Django] #20554: Directly creating model instances on ForeignKey field fails

2014-05-18 Thread Django
#20554: Directly creating model instances on ForeignKey field fails
---+-
 Reporter:  direx  |Owner:
 Type:  Bug|   Status:  closed
Component:  Documentation  |  Version:  1.5
 Severity:  Normal |   Resolution:  duplicate
 Keywords: | Triage Stage:  Accepted
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+-
Changes (by timo):

 * status:  new => closed
 * resolution:   => duplicate


Comment:

 Duplicate of #10811

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.bba02b362172260b05cb53beb0b171f0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #20554: Directly creating model instances on ForeignKey field fails

2014-05-17 Thread Django
#20554: Directly creating model instances on ForeignKey field fails
---+
 Reporter:  direx  |Owner:
 Type:  Bug|   Status:  new
Component:  Documentation  |  Version:  1.5
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Accepted
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+
Changes (by drtyrsa):

 * status:  assigned => new
 * owner:  drtyrsa =>
 * component:  Database layer (models, ORM) => Documentation


Comment:

 I think it's better to document the existing behavior properly. Points to
 mention:

 1. You should save the instance before assigning it as an attribute.
 2. You can event set {{{foo_id}}} attribute directly, but it is less safe,
 as some checks will be skipped. Although it sometimes can be more
 efficient, as there is no need to fetch {{{foo}}} instance from database.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.3360df78e640f90578298c172e6ceec4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #20554: Directly creating model instances on ForeignKey field fails

2014-05-17 Thread Django
#20554: Directly creating model instances on ForeignKey field fails
-+-
 Reporter:  direx|Owner:  drtyrsa
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  1.5
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:   |  Needs documentation:  0
Has patch:  0|  Patch needs improvement:  0
  Needs tests:  0|UI/UX:  0
Easy pickings:  0|
-+-

Comment (by EvilDMP):

 I am not convinced that this should be considered a bug. The behaviour may
 be a little counter-intuitive at first sight, but I don't see that it's
 actually wrong.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.6f4161ab630190856c2139f97c486bd8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #20554: Directly creating model instances on ForeignKey field fails

2014-05-16 Thread Django
#20554: Directly creating model instances on ForeignKey field fails
-+-
 Reporter:  direx|Owner:  drtyrsa
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  1.5
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:   |  Needs documentation:  0
Has patch:  0|  Patch needs improvement:  0
  Needs tests:  0|UI/UX:  0
Easy pickings:  0|
-+-
Changes (by drtyrsa):

 * owner:  nobody => drtyrsa
 * status:  new => assigned


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.a628a38331e47913932a0d183574b132%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #20554: Directly creating model instances on ForeignKey field fails

2013-06-03 Thread Django
#20554: Directly creating model instances on ForeignKey field fails
-+-
 Reporter:  direx|Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  1.5
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:   |  Needs documentation:  0
Has patch:  0|  Patch needs improvement:  0
  Needs tests:  0|UI/UX:  0
Easy pickings:  0|
-+-
Changes (by akaariai):

 * stage:  Unreviewed => Accepted


Comment:

 To me it seems that when saving the `b` in above example we could easily
 and cheaply check that if b.author_id is null, then check if b.author has
 id, and if so use that.

 There is one potential backwards compatibility issue:
 {{{
 b = B.objects.get(somecond)
 assert(b.author.id == b.author_id) # it has an author, the fields have
 same value
 b.author_id = None
 b.save() # The b.author_id is None, so refetch the author_id from
 b.author.id
 }}}
 This is different from what happens currently in Django (where the
 author_id would be set to NULL), and could lead to working code suddenly
 working subtly differently, possibly including data corruption. Seems like
 the worst case of backwards incompatibility to me.

 So, this must be worked around. Maybe save of b.author could somehow set
 b.author_id when b.author.id is set (but I don't believe the author has
 currently reference to b). Or maybe there is some other way to detect that
 b.author has gotten different id, but b.author_id hasn't changed. Still,
 the solution should be fast enough to not have any dramatic memory or
 performance requirements (mainly, `Model.__init__` could be a problem).

 I am going to mark this accepted, but the patch needs to deal with the
 above mentioned backwards incompatibility somehow. This might be
 surprisingly hard to solve correctly.

 (The problem of b.author.id != b.author_id is more generic - a solution
 where it is possible to assert that the user sees always the same value
 for these fields while performance isn't compromised is welcome...)

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.3f2d6e429dbc8c29ab657b31dc4204e9%40djangoproject.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #20554: Directly creating model instances on ForeignKey field fails

2013-06-03 Thread Django
#20554: Directly creating model instances on ForeignKey field fails
-+-
 Reporter:  direx|Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  1.5
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:
 Keywords:   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by direx):

 * needs_better_patch:   => 0
 * type:  Uncategorized => Bug
 * needs_tests:   => 0
 * needs_docs:   => 0


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.7a6478b6baa8ff10b651a7d42f08d4ec%40djangoproject.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.