In your view you can do:

user = request.user

Then you can get Employee with:

employee = Employee.objects.get(user=user)
Then just get the attributes from the models that you need:
eg:

employee.division


On Thu, 21 Nov 2019 at 19:57, Pema Galey <[email protected]> wrote:

> Hi All,
> I am Employee model directly link with User model and Employee holds User
> ID and division from Division model.
> Every employee holds single Division.
>
> class Employee(models.Model):
>     user = models.OneToOneField(User, on_delete=models.CASCADE)
>     division = models.ForeignKey(
>         Division,
>
>
>     )
>
> Now, I want to do following things:
> 1) Get current username /ID
> 2) Get Employee division ID/name
> 3) Display the other data based on Employee's division. [That particular
> Employee should be accessible to their own Division data only]
>
> Someone help me to handle this one please.
>
> Thank you in advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a536c1fb-6852-48f9-8476-463c696926a2%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a536c1fb-6852-48f9-8476-463c696926a2%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOB9TahHDNa36gXMPUbJw2W1drYpm1NGerJ_oc5CajsTRnixrg%40mail.gmail.com.

Reply via email to