I encountered a behavior I can't explain in the site framework and
wonder if I should report this as a bug.

class Video(models.Model):

    sites = models.ManyToManyField(Site)
    on_site = CurrentSiteManager()
    objects = models.Manager()

In manage.py shell, USING A SETTINGS FILE WITH SITE_ID = 1:

In [9]: Site.objects.get(pk=3).video_set.all()
Out[9]: []

But I __do__ have videos on the site with SITE_ID = 3. If I dump the
SQL:

SELECT *
FROM `videos_manager_video`
INNER JOIN `videos_manager_video_sites` ON
(`videos_manager_video`.`id` =
`videos_manager_video_sites`.`video_id`)
INNER JOIN `videos_manager_video_sites` T4 ON
(`videos_manager_video`.`id` = T4.`video_id`) WHERE
(`videos_manager_video_sites`.`site_id` = 1  AND T4.`site_id` = 3 )
LIMIT 21'

The part that bothers me is:

`videos_manager_video_sites`.`site_id` = 1

I don't think this manager should filter videos based on the current
site. I can have very good reasons to manipulate videos from another
site. For example to get all videos from another site, and add them to
this site.

Of course, if I use the settings file with SITE_ID = 3,
site.objects.get(pk=3).video_set.all() returns the expected result.

For now I'll be using Video.objects.filter(sites__in=(3,)) to emulate
Site.objects.get(pk=3).video_set.all() on other sites so it's not
blocking. But it may be hiding some other problems.

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

Reply via email to