Hi,

I opened this as bug report, but I would like to get an feedback here:

https://code.djangoproject.com/ticket/20129#ticket

Copy/pasted bug report:



I have a very weird behavior with this piece of code that took me some 
hours to find out:
 
class ModelA(models.Model, AbstractModel)
    ...

    def items():
        try:
            return self._items_qs_cache
        except AttributeError:
            current_minute = return datetime.now().replace(second=0, 
microsecond=0)
            self._items_qs_cache = self.children_set.filter(published=True, 
publish_date__lte=current_minute)
            return self_items_qs_cache

    parent = models.ForeignKey('self', blank=True, null=True, 
verbose_name=_('parent'), related_name='children_set')
 

Calling the items() function clears the session!
 
But, if instead you replace the following line
 
self._items_qs_cache = self.children_set.filter(published=True, 
publish_date__lte=current_minute)
 

with the following equivalent one
 
self._items_qs_cache = Model.objects.filter(published=True, 
publish_date__lte=current_minute, parent=self)
 

The session does not get cleared.
 
Is this a django bug or am I missing somthing.
 Thank you,

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to