No no, the model will be served on all sites. Individual instances will only be on a single site. So each site will have it's own set of neighborhoods and locations. It's also possible that a neighborhood or location will be on multiple sites.
The problem is that when dealing with a location in the admin interface the select box for neighborhoods shows _all_ the neighborhoods from _all_ the sites which is quite a lot to have to sort through manually. So I'm trying to find a way that the list of neighborhoods could be filtered by site to make it easier to select the right neighborhood. On Mar 27, 10:50 am, Michael <[EMAIL PROTECTED]> wrote: > Let's break down exactly what you are trying to accomplish. You have a > model that you only want to be served only on a certain site. I > thought that flatpages was using a manager to figure this out, but if > actually applies a filter when flatpages is being fallen back on. > > You can create a manager quite simply that filters for site and then > it returns the objects for that site and that then is the query set > that is passed to your views. From there you can deal with figuring > out the other items that you need. > > The documentation for managers is quite > good:http://www.djangoproject.com/documentation/model-api/#managers > Just think that you want as many mangers as sites and you want to > filter the query sets by site. You could probably create a manager > that filters the sites dynmically, but there be monsters with object > caching that you might not want to get into. > > In all reality you could also do this filtering in your views. > > If you are have issues figure out what Site is currently being called > look in settings.SITE_ID > > This is what flatpages does to return the flatpage object: f = > get_object_or_404(FlatPage, url__exact=url, > sites__id__exact=settings.SITE_ID) > > Hope that helps, > > Michael > > On Thu, Mar 27, 2008 at 9:58 AM, Josh <[EMAIL PROTECTED]> wrote: > > > I'm not sure I understand how flatpages can help. I'm trying to limit > > what options show up in a select box in the admin interface so that if > > I have a Location on site A, when I go to select what Neighborhood > > it's in I'm only presented with the Neighborhoods that are also > > associated with site A and not the Neighborhoods from site B. > > > On Mar 26, 10:01 pm, Michael <[EMAIL PROTECTED]> wrote: > > > Django.contrib.flatpages does exactly what you are trying to > > > accomplish. It might be a bit of code to sort through but it is the > > > tried and true method to accomplish the multiple site one object idea. > > > > Hope that helps, > > > > Michael > > > > On Tue, Mar 25, 2008 at 1:47 PM, Josh <[EMAIL PROTECTED]> wrote: > > > > > I'm working on a multi-site project, so most models have a site field. > > > > One particular model, locations, has a site field as well as a > > many-to- > > > > many relationship with the neighborhood model which also has a site > > > > field. What I want is that when editing a location object the > > > > neighborhoods that show up in the select box are only those > > > > neighborhoods that are related to the same site as the location being > > > > edited. > > > > > It's been suggested that writing a custom manager might allow me to do > > > > this, but I'm at a bit of a loss as to how to start. Does anyone have > > > > any tips, or has anyone done somethign similar before? > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---