#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: <https://code.djangoproject.com/ticket/10227#comment:14>
Django <https://code.djangoproject.com/>
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.