yourversion of django before or after qsrf merge?
select_related does not work well with relations that have null = True
On Jun 24, 11:40 pm, bob84123 <[EMAIL PROTECTED]> wrote:
> I'm having a problem with select_related; I'm not sure if it's a bug
> or a problem with my understanding of how it's supposed to work.
>
> Here's some code:
>
> from django.db import models
>
> class Occurrence(models.Model):
> start_time = models.OneToOneField('TimeRepresentation', null = True,
> related_name = "occurrence_start")
>
> class TimeRepresentation(models.Model):
> absolute_time = models.TimeField(null = True)
>
> def do_test():
> Occurrence.objects.all().delete()
> o2 = Occurrence.objects.create()
>
> for o in Occurrence.objects.all():
> if o.start_time != None and o.start_time.absolute_time ==
> None:
> raise "this doesn't raise"
>
> for o in Occurrence.objects.all().select_related('start_time'):
> if o.start_time != None and o.start_time.absolute_time ==
> None:
> raise "but this does"
>
> In each loop, I expect to get an Occurrence with start_time = None.
> The first loop works fine, but in the second loop, instead of getting
> start_time == None, I get an Occurrence with a non-null start_time but
> start_time.absolute_time is null.
>
> Any ideas of what I should do about this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---