Hi,

My app uses a model called Site which is essentially the same as in
the django.contrib.sites framework (domain and name), except that my
model needs an extra field and is related through a foreign key to
another model. (It is related to a model called Client, which stores
all my Clients, and the relationship translates to "Client owns zero
or more Sites").

I am wondering: should I use the django.contrib.sites framework? and,
what would be the best method of extending
django.contrib.sites.models.Site?

I am inclined to try to take advantage of Django's Site model, as
redefining a separate Site system is a very obvious case of redundant,
"boilerplate" code. So my question comes down to: any ideas on how to
do this?

I could use multi-table inheritance and extend the Site class, which
would create a new table that with a foreign key linking it to to the
django_sites table. But I don't like this solution. I would rather use
the Abstract base classes method of inheritance, meaning there is only
one django_sites table. But this would mean hacking the source code of
the django.contrib.sites.models.Site class to add the abstract = True
to the Meta class, etc. Changing the source code doesn't sound like a
good idea either; it could cause issues with upgrading the sites
framework, etc.
There may be a simple solution in the form of a language feature I'm
not familiar with (I'm a Python beginner). I'm thinking along the
lines of modifying django.contrib.sites.models.Site's inner Meta class
at runtime, before extending it with my customized Site model.

Thanks in advance for any ideas.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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