On 10/06/2011 13:37, Benedict Verheyen wrote:
> Hi,
> 
> 
> (2nd attempt, as after a few hours the message still doesn't show up)
> First, to sketch the situation.
> To authenticate users, I use my own login backend. Nothing special, checks 
> the users in AD.
> I have 1 project with all users in it, and other projects have their own 
> limited set of users.
> These "local" users as I call them are not used to login people, only to 
> provide extra
> information, for example, if the user is staff or superuser and so on.
> 
> I did this to provide a central login capability: if a user logs in in 1 of 
> the projects,
> the user is also logged in, in the other projects.
> Now I want a ManyToManyField from a model in one of the other projects to 
> link to
> the users from the central database instead of the it's own user database.
> 
> As i said, the local user database is only used to specify wether a user is 
> staff or superuser and so on.
> 
> For checking users, you can do this, where central_users is the central 
> database
> user = User.objects.using('central_users').get(pk=user_id)
> 
> Is there something similar for models?
> I have a model "Call" that can have several Users linked too.
> ...
> initiator = models.ManyToManyField(User)
> ...
> 
> Is there a way to have this link to the users in the central_users database?
> 
> Regards,
> Benedict
> 

I found that i could change this in the form:

class CallForm(forms.ModelForm):
...
initiator = 
forms.ModelMultipleChoiceField(queryset=User.objects.using('central_users').order_by('first_name'),
widget=FilteredSelectMultiple("User",False,attrs={'rows':'10'}))
...

This showed the users from the central db in the form.
However on save i get an error:

ValueError at /calltracking/call/new/

Cannot add "<User: x.y>": instance is on database "default", value is on 
database "central_users"


If I cannot solve this, I will have to populate the local User database with 
all our users to get them
in the list on the form and save the call.

Anybody know of an idea to get this to work?

Regards,
Benedict

-- 
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 
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