Again, thanks for the other alternatives. Today, I have worked with auth.backends.ModelBackend and it seems it would be possible to separate user resources (like if the route namespace is "myapp", then go with Customer table) if get_user(self, user_id) method is called with request parameter. It's only called by auth.get_user(request) which already has the request parameter in order to obtain backend session key. I had to change original Django source code to send extra request parameter to ModelBackend.get_user (which is really embarrassing, I know). Then I used monkey patching technique in my application code to keep Django source code original. (which is also embarrassing)
The reason that I really want to do is the database will be used by another framework in Java and my teammates insist on keeping customers data on another table (It also seems reasonable to me). I think your separated project solution is the legit way to to something like that but the problem is I have to run two python instances in server and it will become harder to manage these instances. Also AFAIK they will have to use different ports I will have to use reverse proxy to attach the other project to a path. Sincerely, Burak Emre On Thursday, October 10, 2013 3:09:22 AM UTC+3, Russell Keith-Magee wrote: > > > On Thu, Oct 10, 2013 at 6:00 AM, Burak Emre Kabakcı > <[email protected]<javascript:> > > wrote: > >> Thanks for the suggestions. >> >> @Andre Terra I figured out that my solution doesn't work actually. >> Custom managers is not useful in my case because underlying auth system is >> still same, it means it will also use same same session tables, cookies etc. >> >> @Russell Keith-Magee Sorry, I couldn't understand what you mean in your >> second paragraph. What I'm trying to do is exactly what you're suggesting, >> in the example there is an app called "myapp" and I resolve the url and if >> the request is routed to a view in "myapp" app I change AUTH_USER_MODEL >> setting because AFAIK all applications use a shared settings.py file. If >> there's a way to use different settings for each application, please let me >> know. >> Otherwise if you're suggesting that I should start new project that has >> its manage.py and settings.py I think it would be much more painful. >> > > Yes - I mean having two separate projects, with two separate settings > files, etc. > > As for being "more painful" -- more painful than what? You haven't > proposed an alternative that will actually work - your middleware-based > solution is fundamentally flawed, for the reasons I described in the first > paragraph of my original response. > > It's not like we're talking about a lot of code here. You need to have 2 > different settings files. However, those two settings files can share a > common base -- at a bare minimum, it only needs to say: > > --- > from common_settings import * > > AUTH_USER_MODEL = 'project1.User' > --- > > where common_settings is a file that contains the settings common between > the two projects. Yes, there's some complexity here. But then, you're the > one with a project with two different concepts of User. It doesn't matter > *what* you do, there's going to be complexity. > > It's also worth pointing out the other alternatives: > > * Use a *single* user model, but have *profiles* to cover the different > "types" of user. If you need a foreign key, use a foreign key to the > *profile*, not the User. > > * Write your own authentication backend. Django's auth backend is > pluggable, and isn't bound to auth.User at all. > > Yours > Russ Magee %-) > -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/d9b7106b-5e30-4275-ba26-112f324031c1%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
