and of course, a save() on the model would be necessary: class ClientModel(models.Model): """ An abstract base class model that provides a link to client table """ client = Client()
def save(self): client = <current client> super(ClientModel, self).save() class Meta: abstract = True On Oct 13, 5:49 pm, Daniel <[EMAIL PROTECTED]> wrote: > Would it not be possible to create a base model and model manager that > specifies a client, and override the default django.db.models.Model > and django.db.models.Manager classes? Something like this: > > class Client(models.Model): > client_name = models.CharField(max_length=64) > # etc... > > class ClientManager(models.Manager): > def get_query_set(self): > client = <current client - retrieved from middleware global?> > return super(ClientManager, > self).get_query_set().filter(client=client) > > class ClientModel(models.Model): > """ > An abstract base class model that provides a link to client table > """ > client = Client() > > class Meta: > abstract = True > > django.db.models.Model = ClientModel > django.db.models.Manager = ClientManager > > I haven't tested this... this would need to be imported early, before > any of the apps are loaded, and in get_query_set one would need a way > to determine the client that corresponds with the current url - I > think some middleware that inspects the request should be able to > cache that away. > > Anyone know if this is possible, or am I way off base? > > Dan > > On Oct 10, 2:34 pm, mguthrie <[EMAIL PROTECTED]> wrote: > > > I've been looking into Django for building something that is more web > > application than it is website. I understand that Django has been > > developed in a sort of CMS mindset but to date I haven't found any > > reason why it couldn't create non-content centric web apps as well. > > > My project requirements are as follows: > > > 1.) I need to be able to host this project for multiple clients. No > > customization, just everybody using the same thing. Therefore ideally > > they should all share the same codebase. > > 2.) Each client should have their own user table/authentication since > > I want client A to be able to have a user named john.doe and client B > > to as well. I would not mind if they shared the same table but they > > needed to provide a client id so the login can differentiate. > > 3.) Media should be separate per client. Client A media should not be > > mixed with Client B or vice versa. > > 4.) Database either needs to be single db per client or one large db > > with multiple prefixed tables per client. So each client would get > > their own users table (or shared table with client id field), tables > > for data, etc. > > > I've researched the options available and here's what I've found > > (correct me if I'm wrong): > > 1.) I can host each client separately by providing a different > > <Location> for each and specifying a different settings file. This > > should allow me to specify separate DB's, media locations, etc but I'm > > concerned about the overhead of hosting them. I've read that for each > > instance of Django requires another python interpreter. If that is > > the case wouldn't I run out of RAM quickly hosting several clients? > > Is there a way I can do this using only one instance of Django? If I > > use Django with multiple <Location>'s per client would that be one > > Django instance or multiple? Is mod_python not the way to go for this > > project? > > 2.) I can use django.contrib.sites but every client shares the > > authentication. Is there a way I can specify a client id to > > distinguish Client A's john.doe from Client B's? If I do this can I > > specify where media for either would go? How about they all share the > > same DB but have different table prefixes? > > > I know it's a lot but I wanted to be as specific as I could so I don't > > waste someone's time. Is Django probably the wrong framework for this > > project? Should this be a Pylons/Turbogears thing or what? > > > All ideas/critiques/reworkings will be accepted. Thanks in advance. > > > -MG --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---