I am importing app level views like this in `urls.py` from . import views On Thu, Apr 30, 2020 at 1:35 PM 'Amitesh Sahay' via Django users < django-users@googlegroups.com> wrote:
> You can also try keeping the same name for the endpoint as below > > path('endpoint/', views.Endpoint.as_view(), name='endpoint'), > > > Sent from Yahoo Mail on Android > <https://go.onelink.me/107872968?pid=InProduct&c=Global_Internal_YGrowth_AndroidEmailSig__AndroidUsers&af_wl=ym&af_sub1=Internal&af_sub2=Global_YGrowth&af_sub3=EmailSignature> > > On Thu, 30 Apr 2020 at 23:52, Milson Munakami > <milson...@gmail.com> wrote: > Hi Sahay, > > That is already > > > path('endpoint/', views.Endpoint.as_view(), name='get_endpoint'), > > > On Thu, Apr 30, 2020 at 1:15 PM 'Amitesh Sahay' via Django users < > django-users@googlegroups.com> wrote: > > It should be Endpoint.as_view() > > Sent from Yahoo Mail on Android > <https://go.onelink.me/107872968?pid=InProduct&c=Global_Internal_YGrowth_AndroidEmailSig__AndroidUsers&af_wl=ym&af_sub1=Internal&af_sub2=Global_YGrowth&af_sub3=EmailSignature> > > On Thu, 30 Apr 2020 at 17:35, Milson Munakami > <milson...@gmail.com> wrote: > > Can anyone please help me to resolve this issue? > > https://stackoverflow.com/q/61514512/1316060 > > My url path in project's url.py is defined as follows: > > path('endpoint/', views.Endpoint.as_view(), name='get_endpoint'), > > The views.py include the following class to handle this routing: > > @method_decorator(csrf_exempt, name='dispatch') class Endpoint(View): > def get(self, request, *args, **kwargs): > ############ Here I can see the User Session ########## > if not request.user.is_authenticated: > return redirect('authentication_router') > > return redirect( > > 'https://app.globus.org/file-manager?method=POST&action=%s&cancelurl=%s&folderlimit=1&filelimit=0&label=%s' > % ( > request.build_absolute_uri(), "/", "To Transfer your Files Select > the Folder first!") > ) > > def post(self, request, *args, **kwargs): # On return from OAuth Page > ############ Here, User Session return nothing so user is > AnonymousUser ########## > if request.POST.get('folder[0]'): # A Endpoint folder was selected > endpoint_path = os.path.join(request.POST.get('path'), > request.POST.get('folder[0]')) > else: > endpoint_path = request.POST.get('path') > > profile = request.user.userprofile # request.user does not has > userprofile > profile.endpoint_path = endpoint_path > profile.save() > > return HttpResponseRedirect(reverse('authentication_router')) > > The problem is when the get is called it finds the request.user value as > authenticated user but once the redirect from OAUTH page with POST hits the > class it loss all request user session and gives error at this line: > > profile = request.user.userprofile > > As, request.user seems loss its session and has value of AnonymousUser even > though till GET method it is preserving the user's login session values. > > My settings.py file includes: > > INSTALLED_APPS = [ > 'django.contrib.admin', > 'django.contrib.auth', > 'django.contrib.contenttypes', > **'django.contrib.sessions',** > 'django.contrib.messages', > 'django.contrib.staticfiles', > 'django.contrib.sites', > 'myapp',] > > MIDDLEWARE = [ > 'django.middleware.security.SecurityMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.middleware.common.CommonMiddleware', > 'django.middleware.csrf.CsrfViewMiddleware', > **'django.contrib.auth.middleware.AuthenticationMiddleware',** > 'django.contrib.messages.middleware.MessageMiddleware', > 'django.middleware.clickjacking.XFrameOptionsMiddleware',] > > I am testing it in localhost:8000 .Please let me know what I am missing > this code. Same code is perfectly working in Django 1.8 and Python 2.7. > Recently, I am trying to upgrade it to work with Django 3 and Python 3. > Only difference I can see is in settings.py in Django 1.8 version > includes: > 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',in > MIDDLEWARE_CLASSES which is removed in latest version of Django. > > -- > Thank you, > > Milson > > > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > Virus-free. > www.avg.com > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > <#m_-1761585692148730265_m_-3725953101382322326_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > > -- > 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/CAP1qhGui2o%3DDJD57Rq7GaiVO-s9wOgSdw1G-bNLPSYCL9Wkeuw%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAP1qhGui2o%3DDJD57Rq7GaiVO-s9wOgSdw1G-bNLPSYCL9Wkeuw%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/1981496808.1824222.1588270514644%40mail.yahoo.com > <https://groups.google.com/d/msgid/django-users/1981496808.1824222.1588270514644%40mail.yahoo.com?utm_medium=email&utm_source=footer> > . > > -- > Thank you, > > Milson Munakami > > Mobile: 208.220.2943 > > -- > 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/CAP1qhGvo2X8%2BAPvqQGoOuVFOfhkmC%3DCkiByxfow6s4YVSzawnA%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAP1qhGvo2X8%2BAPvqQGoOuVFOfhkmC%3DCkiByxfow6s4YVSzawnA%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/1427974624.1821610.1588271666097%40mail.yahoo.com > <https://groups.google.com/d/msgid/django-users/1427974624.1821610.1588271666097%40mail.yahoo.com?utm_medium=email&utm_source=footer> > . > -- Thank you, Milson Munakami Mobile: 208.220.2943 <208.220.2943> -- 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/CAP1qhGtr8Hy_Bc32E2-mB-XFLH6gDH4KxgtNUKfRx3Q8oxKmOA%40mail.gmail.com.