On Apr 1, 3:16 pm, Митко Масарлиев <m.masarl...@gmail.com> wrote:
> soniiic wrote:
>
> > On Mar 31, 10:31 pm, Mitko Masarliev <m.masarl...@gmail.com> wrote:
>
> >> I have application with table name clients. Clients has one to one
> >> relation with django users and in all app logic I check clients id by
> >> request.user.id, In some cases user_id is not same as clients_id. This
> >> is the problem, so I am trying to change request.user.id to be equal to
> >> clients_id and this will halp me rewriting many classes and methods
>
> > if you got a one to one relationship why can't you just do this:
> > client = Clients.objects.filter(user=request.user)
>
> > ...where user is your relationship field in the Client model.
>
> Becouse I have other table with relation to clients I and these tables
> don't have relation with users
>
> --
>
> Regards,
> Mitko Masarliev
> Junior Php Developer
> m.masarl...@viscomp.bg <mailto:m.masarl...@viscomp.bg>
> Mobile: +359 898 563 274
>
>         *Viscomp EOOD*
> 92V "Hristo Botev" Blvd
> 4000 Plovdiv
> Bulgaria        
> Tel: +359 32 655 175
> Fax: +359 32 655 176www.viscomp.bg<http://www.viscomp.bg>

I'm new to django myself, but i don't think this can be done.  You got
to set up a relationship in your Clients model to user. i think the
common practise is to use a foreign key with "unique=True" so that
only one client is made per user.

like such:
user = models.ForeignKey(User, unique=True)
--~--~---------~--~----~------------~-------~--~----~
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