#18416: Query fails when SimpleLazyObject evaluates to None
-------------------------------------+-------------------------------------
Reporter: Bouke Haarsma | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 1.4
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Ben Youngblut):
I also am curious if anyone came up with a good solution for this. I use
my own custom user object, and also a organization object that are both
attached to the request in middlewares as `SimpleLazyObjects` that have a
`None` value if they are not logged in or if the logged in user is not
part of an organization. Currently attaching to models is a real pain
{{{
Action.objects.create(
organization=request.organization if request.organization else None,
...
)
}}}
And what is really bad is that if you forget this and don't test with a
user without an organization it can easily go unnoticed!
--
Ticket URL: <https://code.djangoproject.com/ticket/18416#comment:7>
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 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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/063.ca1ae9cbba34cc480026f8f445449d14%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.