'user = User.objects.get(email=email) '  i have to pass this 'user'
instance  from login function to detail function  in django

  views.py:

        def login(request):
            if request.method == 'POST':
                email  = request.POST['email']
                password = request.POST['password']

                user = User.objects.get(email=email)
                if user.password == password:

                    if user.type == 'Manager':
                        return redirect('company-add')


                    if user.type == 'Normal':
                        details = user            # i want this instance
user  to be passed onto detail function


                        #return
redirect('company-detail',{'details':details})


                else:
                    messages.success(request, 'invalids credentials')
                    return redirect('company-login')

            else:
                return render(request, 'company/login.html')

        def detail(request):

                return render(request, 'company/detail.html')



    urls.py:
        from django.urls import path
        from .import views

        urlpatterns=[
            path('', views.home, name='company-home'),
            path('register/', views.register, name='company-register'),
            path('detail/', views.detail, name='company-detail'),
            path('login/', views.login, name='company-login'),
            path('add/', views.add, name='company-add'),



On Wed, Nov 20, 2019 at 9:07 PM Bob Gailer <bgai...@gmail.com> wrote:

> On Nov 20, 2019 10:27 AM, "Paras Jain" <parasjain...@gmail.com> wrote:
> >
> > how to take pass one object of one function to other in django
>
> I do not understand your question. Perhaps someone else will understand it
> and give you the answer you're seeking. If you don't get an answer please
> try restating your question or give us an example of what you're trying to
> do.
>
> Bob Gailer
>
> --
> 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 django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAP1rxO4fZcKofjNFkF9VNkW%3DMPrRD%3DcBfOz8xKq-z2_HcHqhKA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAP1rxO4fZcKofjNFkF9VNkW%3DMPrRD%3DcBfOz8xKq-z2_HcHqhKA%40mail.gmail.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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMtmBS-oHtP-%3DhV8vh_w6%3Dtbz1gmpH5%2BvYnnzhH8g4ZDJ32jrA%40mail.gmail.com.

Reply via email to