Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2012-09-26 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
-+-
 Reporter:  rvdrijst |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:  onetoone related |  Needs documentation:  0
  expection null |  Patch needs improvement:  0
Has patch:  0|UI/UX:  0
  Needs tests:  0|
Easy pickings:  0|
-+-
Changes (by frankoid):

 * cc: frankoid (added)


-- 
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2012-08-29 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
-+-
 Reporter:  rvdrijst |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:  onetoone related |  Needs documentation:  0
  expection null |  Patch needs improvement:  0
Has patch:  0|UI/UX:  0
  Needs tests:  0|
Easy pickings:  0|
-+-
Changes (by cvrebert):

 * cc: cvrebert (added)


-- 
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2012-04-10 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
-+-
 Reporter:  rvdrijst |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  SVN
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:  onetoone related |  Needs documentation:  0
  expection null |  Patch needs improvement:  0
Has patch:  0|UI/UX:  0
  Needs tests:  0|
Easy pickings:  0|
-+-
Changes (by aaugustin):

 * cc: aaugustin (added)


Comment:

 I just spent some time on this bug while investigating related problems.

 I agree that the proper solution is to add a `related_default` parameter
 to `OneToOneField`. Like `default`, this parameter could be a value or a
 callable.

 Independently, there are some bugs and inconsistencies in the caching of
 the lack of a value (#13839 and #17439). Fixing this bug would provide a
 way to hide some of these problems, but not address their root cause.

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2012-01-08 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
-+-
 Reporter:  rvdrijst |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  SVN
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:  onetoone related |  Needs documentation:  0
  expection null |  Patch needs improvement:  0
Has patch:  0|UI/UX:  0
  Needs tests:  0|
Easy pickings:  0|
-+-

Comment (by lrekucki):

 Replying to [comment:18 sebastian]:
 > Alright, here is another inconsistent behavior that falls in the lines
 of raising or not raising an exception.
 >
 > The behavior of the reverse lookup for one-to-one-fields changes when
 `select_related` has been called on the reverse relation. In that case,
 accessing the reverse relation does not raise an exception but returns
 `None` in the case of a missing related object. This feels rather strange
 to me, it should either always raise an exception or never.

 This is a bug described in #13839. In context of this ticket, it should
 always raise an exception, unless {{{related_null=True}}} is given, in
 which case it should always return {{{None}}}.

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2011-10-18 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
-+-
 Reporter:  rvdrijst |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  SVN
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:  onetoone related |  Needs documentation:  0
  expection null |  Patch needs improvement:  0
Has patch:  0|UI/UX:  0
  Needs tests:  0|
Easy pickings:  0|
-+-

Comment (by sebastian):

 Alright, here is another inconsistent behavior that falls in the lines of
 raising or not raising an exception.

 The behavior of the reverse lookup for one-to-one-fields changes when
 `select_related` has been called on the reverse relation. In that case,
 accessing the reverse relation does not raise an exception but returns
 `None` in the case of a missing related object. This feels rather strange
 to me, it should either always raise an exception or never.

 I am not sure if gsakkis' snippet addresses this issue.

 Here is an example:

 {{{
 class A(models.Model):
 pass

 class B(models.Model):
 a = models.OneToOneField(A)

 
 a = A.objects.create()
 A.objects.get(pk=a.pk).b  # raises B.DoesNotExist
 A.objects.select_related('b').get(pk=a.pk).b  # returns None
 }}}

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2011-10-18 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
-+-
 Reporter:  rvdrijst |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  SVN
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:  onetoone related |  Needs documentation:  0
  expection null |  Patch needs improvement:  0
Has patch:  0|UI/UX:  0
  Needs tests:  0|
Easy pickings:  0|
-+-
Changes (by sebastian):

 * cc: sebastian (added)


Comment:

 I'd also like to see the functionality of the reverse side not throwing an
 exception. This would also make both sides of the one-to-one relation
 behave more symmetric. I agree that an additional parameter is the way to
 go, since all four types of blank/non-blank make sense (comment:7).

 Can gsakkis' snippet (comment:10) be adapted to the current trunk version?
 I agree that passing `None` or constant values to `related_default` should
 be possible in addition to passing in functions/lambdas, as it makes the
 model definition much cleaner in the case of simple values.

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2011-08-22 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
-+-
   Reporter:  rvdrijst   |  Owner:  nobody
   Type:  New| Status:  new
  feature|  Component:  Database layer
  Milestone: |  (models, ORM)
Version:  SVN|   Severity:  Normal
 Resolution: |   Keywords:  onetoone related
   Triage Stage:  Accepted   |  expection null
Needs documentation:  0  |  Has patch:  0
Patch needs improvement:  0  |Needs tests:  0
  UI/UX:  0  |  Easy pickings:  0
-+-
Changes (by gsakkis):

 * cc: gsakkis (removed)


-- 
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2011-08-22 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
-+-
   Reporter:  rvdrijst   |  Owner:  nobody
   Type:  New| Status:  new
  feature|  Component:  Database layer
  Milestone: |  (models, ORM)
Version:  SVN|   Severity:  Normal
 Resolution: |   Keywords:  onetoone related
   Triage Stage:  Accepted   |  expection null
Needs documentation:  0  |  Has patch:  0
Patch needs improvement:  0  |Needs tests:  0
  UI/UX:  0  |  Easy pickings:  0
-+-

Comment (by olau):

 Rereading this, can I suggest that related_default does not have to be a
 function? It would make things a bit clearer if one could say
 related_default=None instead =lambda x: None.

 I realize this means you have to apply slight cleverness when defining the
 parameter since you can't use None, e.g.

 {{{
 class RelatedDefaultRaiseException: pass

 def __init__(..., related_default=RelatedDefaultRaiseException):
 if related_default == RelatedDefaultRaiseException:
 # turn on exception raising behaviour
 }}}

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2011-08-19 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
-+-
   Reporter:  rvdrijst   |  Owner:  nobody
   Type:  New| Status:  new
  feature|  Component:  Database layer
  Milestone: |  (models, ORM)
Version:  SVN|   Severity:  Normal
 Resolution: |   Keywords:  onetoone related
   Triage Stage:  Accepted   |  expection null
Needs documentation:  0  |  Has patch:  0
Patch needs improvement:  0  |Needs tests:  0
  UI/UX:  0  |  Easy pickings:  0
-+-
Changes (by anonymous):

 * ui_ux:   => 0


Comment:

 I came up with this work around as well, to check that when a user is
 saved it has an associated userprofile

 @receiver(post_save, sender=User)
 def user_saved(sender, instance, created, **kwargs):
 if not hasattr(instance, 'userprofile'):
 user_profile = UserProfile()
 user_profile.user = instance
 user_profile.save()

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2011-04-28 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
-+-
   Reporter:  rvdrijst   |  Owner:  nobody
   Type:  New| Status:  new
  feature|  Component:  Database layer
  Milestone: |  (models, ORM)
Version:  SVN|   Severity:  Normal
 Resolution: |   Keywords:  onetoone related
   Triage Stage:  Accepted   |  expection null
Needs documentation:  0  |  Has patch:  0
Patch needs improvement:  0  |Needs tests:  0
 |  Easy pickings:  0
-+-
Changes (by lukeplant):

 * has_patch:  1 => 0
 * type:  Bug => New feature
 * easy:   => 0
 * stage:  Design decision needed => Accepted


Comment:

 It looks to me that the consensus is that raising the `DoesNotExist`
 exception does make sense (at least in some cases, and we have to take the
 general case). The argument gsakkis makes seems sensible, so his/her
 solution is preferable. It would also make it very easy to solve the
 original problem i.e. just provide `related_default=lambda: None`.

 But this is definitely a feature, not a bug, so changing accordingly.

 I'm removing the 'has patch' flag since we don't have a patch that
 implements the chosen solution.

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2011-04-01 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
-+-
   Reporter:  rvdrijst   |Owner:  nobody
   Type:  Bug|   Status:  new
  Milestone: |Component:  Database layer
Version:  SVN|  (models, ORM)
 Resolution: | Severity:  Normal
   Triage Stage:  Design | Keywords:  onetoone related
  decision needed|  expection null
Needs documentation:  0  |Has patch:  1
Patch needs improvement:  0  |  Needs tests:  0
-+-
Changes (by SmileyChris):

 * type:   => Bug
 * severity:   => Normal
 * milestone:  1.3 =>


-- 
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2010-10-23 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
---+
  Reporter:  rvdrijst  | Owner:  nobody 

Status:  new   | Milestone:  1.3

 Component:  Database layer (models, ORM)  |   Version:  SVN

Resolution:|  Keywords:  onetoone 
related expection null
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  0 |  
---+
Changes (by anonymous):

  * version:  1.0 => SVN
  * milestone:  => 1.3

-- 
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 post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2010-09-28 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
---+
  Reporter:  rvdrijst  | Owner:  nobody 

Status:  new   | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  1.0

Resolution:|  Keywords:  onetoone 
related expection null
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  0 |  
---+
Comment (by gsakkis):

 I ran into the same problem although in my case a hypothetical
 `related_null=True` would not help; a new default object would have be
 created. So instead of `related_null` I wrote a OneToOneField that uses
 `related_default`, a callable `lambda instance: value`. I posted the
 snippet at http://gist.github.com/601977.

 To me this seems more elegant, not only because it is a generalization of
 the `related_null` (just set `related_default=lambda instance: None`) but
 because `null` (and by association `related_null`) is a DB-level
 parameter, it determines whether a DB column is created as NULL or NOT
 NULL. In the case of a OneToOneField, the related model does not have a
 column linking to the model where the OneToOneField was defined (no
 `shop_id` column in the place table), so it doesn't make sense to say it's
 null.

-- 
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 post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2010-09-27 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
---+
  Reporter:  rvdrijst  | Owner:  nobody 

Status:  new   | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  1.0

Resolution:|  Keywords:  onetoone 
related expection null
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  0 |  
---+
Changes (by gsakkis):

 * cc: gsakkis (added)

-- 
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 post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2010-09-14 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
---+
  Reporter:  rvdrijst  | Owner:  nobody 

Status:  new   | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  1.0

Resolution:|  Keywords:  onetoone 
related expection null
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  0 |  
---+
Changes (by Jonas):

 * cc: dja...@vonposer.de (added)

Comment:

 Replying to [comment:7 olau]:
 > So I think we need to model it with a separate parameter, e.g.
 related_null=True. That would also be backwards-compatible.

 This seems an elegant solution. I would really like to have this
 functionality, as it makes extending the User model much easier. For
 instance, we have a Member model with a OneToOneField to User. Since I
 can't add a property to User (except by monkeypatching it), I have to wrap
 every access to request.user.member with a try/except block.

-- 
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 post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2010-05-10 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
---+
  Reporter:  rvdrijst  | Owner:  nobody 

Status:  new   | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  1.0

Resolution:|  Keywords:  onetoone 
related expection null
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  0 |  
---+
Changes (by olau):

 * cc: o...@iola.dk (added)

Comment:

 I've run into the case where every Shop has a Place, but some places don't
 have a shop. So I think we need to model it with a separate parameter,
 e.g. related_null=True. That would also be backwards-compatible. Aren't
 there four cases? So we need two bits to describe them:
 {{{
 one   to  one
 zero or one   to  one
 one   to  zero or one
 zero or one   to  zero or one
 }}}

-- 
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 post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2009-05-15 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
---+
  Reporter:  rvdrijst  | Owner:  nobody 

Status:  new   | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  1.0

Resolution:|  Keywords:  onetoone 
related expection null
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  0 |  
---+
Changes (by RaceCondition):

 * cc: eal...@gmail.com (added)

-- 
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 post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2009-05-15 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
---+
  Reporter:  rvdrijst  | Owner:  nobody 

Status:  new   | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  1.0

Resolution:|  Keywords:  onetoone 
related expection null
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  0 |  
---+
Comment (by RaceCondition):

 Assuming {{{related_name='foobar'}}} is desired, the workaround would be
 to use {{{related_name='_foobar'}}} and then write a property in the
 related model that looks like this:

 {{{
 def foobar(self):
 try:
 return self._foobar
 except Foobar.DoesNotExist:
 return None
 }}}

-- 
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 post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2009-03-01 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
---+
  Reporter:  rvdrijst  | Owner:  nobody 

Status:  new   | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  1.0

Resolution:|  Keywords:  onetoone 
related expection null
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  0 |  
---+
Comment (by mtredinnick):

 This has come up before (#3106). I've closed that as dupe, simply because
 the description here is more useful.

-- 
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 post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2009-02-28 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
---+
  Reporter:  rvdrijst  | Owner:  nobody 

Status:  new   | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  1.0

Resolution:|  Keywords:  onetoone 
related expection null
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  0 |  
---+
Changes (by jacob):

  * needs_better_patch:  => 0
  * stage:  Unreviewed => Design decision needed
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 I'm not entirely sure what the correct behavior here ought to be: the fact
 that `Shop.place` may be null doesn't necessarily imply that `Place.shop`
 also may be null. That is, it may be correct for some situations that a
 `Shop` may not have a `Place` but that `Place` always has an associated
 `Shop`.

-- 
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 post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2009-02-10 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
-+--
 Reporter:  rvdrijst |   Owner:  nobody
   Status:  new  |   Milestone:  post-1.0  
Component:  Database layer (models, ORM) | Version:  1.0   
 Keywords:  onetoone related expection null  |   Stage:  Unreviewed
Has_patch:  1|  
-+--
 Referencing a {{{OneToOneField}}} with {{{null=True}}} (i.e. it's
 optional) when there is no value set will return {{{None}}}, as expected.
 However, referencing the reverse side of the relation does not follow this
 behavior and raises a {{{DoesNotExist}}} exception.

 For example, in the following situation where {{{Shop}}}s have optionally
 a {{{Place}}} (e.g. webshops need not have a physical location):
 {{{
 class Place(models.Model)
 address = models.CharField(max_length=80)
 class Shop(models.Model)
 place = models.OneToOneField(Place, null=True)
 name = models.CharField(max_length=50)
 website = models.URLField()
 }}}
 This ''does'' work as expected:
 {{{
 >>> s1 = Shop.objects.create(name='Shop', website='shop.com')
 >>> print s1.place
 None
 }}}
 But this ''doesn't'' work as expected:
 {{{
 >>> p1 = Place.objects.create(address='123 somestr')
 >>> p1.shop
 ... [exception stack trace] ...
 DoesNotExist: Shop matching query does not exist.
 }}}
 I would expect this to be {{{None}}} when {{{null}}} is allowed on the
 {{{OneToOneField}}}.

 Please correct my if I'm wrong.

 I have attached a patch to fix this (checking if {{{null}}} is allowed and
 returning {{{None}}} or raising the exception appropriately), including
 tests.

 Unfortunately this is slightly backwards incompatible, since someone may
 currently rely on the exception being thrown.

-- 
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 post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---