List Info

Thread: can contrib.sites.models (Site) belong to an application model?




can contrib.sites.models (Site) belong to an application model?
country flaguser name
United States
2007-10-22 16:14:51
Hey all

Just a quick one that I dont seem to be able to find
anywhere in the
documentation; Is it possible for one of my app models to
have-many
sites?

I have a model called Partner which i would like to
have-many Sites,
is this possible? Or is this too ingrained in the django
code itself?

Cheers

Tim


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


Re: can contrib.sites.models (Site) belong to an application model?
user name
2007-10-23 06:02:09
On 10/23/07, Tim Perrett <googletimperrett.com> wrote:
>
> I have a model called Partner which i would like to
have-many Sites,
> is this possible? Or is this too ingrained in the
django code itself?

Sure - Site is just a model in the contrib 'sites'
application, so you
can import and reference the Site model just like you would
for any
other Many-to-many relation:

from django.db import models
from django.contrib.sites.models import Site

class Partner(models.Model):
    ... your attributes here....
    sites = models.ManyToManyField(Site)

Yours,
Russ Magee %-)

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


Re: can contrib.sites.models (Site) belong to an application model?
country flaguser name
United States
2007-10-23 06:35:23
For sure, ive been playing with it and have seen that I can
have one-
to-many (Site has-many Partners) and ManyToMany, but I was
looking to
have it so that one partner has many sites? Is the
ManyToMany the only
way to do this? As in terms of a DB schema, its not a many
to many
relationship.

Ideally I would like to be able to determine what partner
that site
belonged to, is that even possible? It just seemed to me
that there
might well not be a way of doing it???

Thanks for any help in advance

Tim




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


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )