Wednesday, November 6, 2024

Re: django.contrib.auth.update_session_auth_hash not working after change password

@cseb Where did you get that Django Code?

On Wed, 6 Nov 2024 at 15:07, Ruby <dev.rubyshell@gmail.com> wrote:
Your code needs to be refactored, here is the real deal, your ChangePassowrdFrom is missing `request`, it should be as it is below
form = grandmas4hire.forms.ChangePasswordForm(request, request.POST)


On Wed, Nov 6, 2024 at 8:20 PM cseb...@gmail.com <cseberino@gmail.com> wrote:
Ruby

Thank you very much.  Here is my code...


INV        = grandmas4hire.models.Invitation  

...

def add_url_param(url, param, arg):                                             
        prefix = "&" if "?" in url else "/?"                                    
                                                                                
        return url + prefix + f'{param}={str(arg).replace(" ", "+")}'           
 
---

@django.contrib.auth.decorators.login_required                                  
def change_password(request):                                                  
        user = request.user                                                    
        msg  = request.GET.get("msg")                                          
        if request.method == "POST":                                            
                form = grandmas4hire.forms.ChangePasswordForm(request.POST)    
                if form.is_valid():                                            
                        new_password = form.cleaned_data["new_password"]        
                        inv          = INV.objects.get(user = user)            
                        inv.user.set_password(new_password)                    
                        inv.user.save()                                        
                        django.contrib.auth.update_session_auth_hash(request,  
                                                                     user)      
                        url          = add_url_param("/change_password",        
                                                     "msg",                    
                                                     "Password+changed.")      
                        reply        = django.shortcuts.redirect(url)          
                else:                                                          
                        reply = django.shortcuts.render(request,                
                                                        "change_password.html",
                                                        {"form" : form})        
        else:                                                                  
                form  = grandmas4hire.forms.ChangePasswordForm()                
                reply = django.shortcuts.render(request,                        
                                                "change_password.html",        
                                                {"form" : form,                
                                                 "msg"  : msg})                
                                                                               
        return reply                          

On Tuesday, November 5, 2024 at 5:41:09 PM UTC-6 Ruby wrote:
How was it implemented?
Show a snippet from your code
See how it was used in my code

form = ChangePasswordForm(request, request.POST)
if form.is_valid():
user = form.save()
update_session_auth_hash(request, user)
messages.success(
request, "Your password has been successfully updated")
return redirect(request.META.get('HTTP_REFERER'))

On Tue, Nov 5, 2024 at 10:30 PM cseb...@gmail.com <cseb...@gmail.com> wrote:
When I change a password, users are logged out.
Django recommends keeping users logged in
by calling django.contrib.auth.update_session_auth_hash(request, user).

This is not working in a Django website of mine.
They must log in again!?

There are no error messages.  Is there any way I can provide
more details?

Chris

--
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...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/04908d1c-a1e4-41ea-afd8-e227f78af8bcn%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/0c0c2c50-5064-4e9d-a579-f0ddb323c11an%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/CAPUD46tCgtE4bK6yrrZ18FuxE4oTsvkda%2BLG2S8Fz14pxrkb%3DA%40mail.gmail.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/CAGiSraBJ4SuFGgJKiMWvuspOM0Sp3%3DKgKVb%2BAfoHQDkG6%3D2HsQ%40mail.gmail.com.

Re: django.contrib.auth.update_session_auth_hash not working after change password

Your code needs to be refactored, here is the real deal, your ChangePassowrdFrom is missing `request`, it should be as it is below
form = grandmas4hire.forms.ChangePasswordForm(request, request.POST)


On Wed, Nov 6, 2024 at 8:20 PM cseb...@gmail.com <cseberino@gmail.com> wrote:
Ruby

Thank you very much.  Here is my code...


INV        = grandmas4hire.models.Invitation  

...

def add_url_param(url, param, arg):                                             
        prefix = "&" if "?" in url else "/?"                                    
                                                                                
        return url + prefix + f'{param}={str(arg).replace(" ", "+")}'           
 
---

@django.contrib.auth.decorators.login_required                                  
def change_password(request):                                                  
        user = request.user                                                    
        msg  = request.GET.get("msg")                                          
        if request.method == "POST":                                            
                form = grandmas4hire.forms.ChangePasswordForm(request.POST)    
                if form.is_valid():                                            
                        new_password = form.cleaned_data["new_password"]        
                        inv          = INV.objects.get(user = user)            
                        inv.user.set_password(new_password)                    
                        inv.user.save()                                        
                        django.contrib.auth.update_session_auth_hash(request,  
                                                                     user)      
                        url          = add_url_param("/change_password",        
                                                     "msg",                    
                                                     "Password+changed.")      
                        reply        = django.shortcuts.redirect(url)          
                else:                                                          
                        reply = django.shortcuts.render(request,                
                                                        "change_password.html",
                                                        {"form" : form})        
        else:                                                                  
                form  = grandmas4hire.forms.ChangePasswordForm()                
                reply = django.shortcuts.render(request,                        
                                                "change_password.html",        
                                                {"form" : form,                
                                                 "msg"  : msg})                
                                                                               
        return reply                          

On Tuesday, November 5, 2024 at 5:41:09 PM UTC-6 Ruby wrote:
How was it implemented?
Show a snippet from your code
See how it was used in my code

form = ChangePasswordForm(request, request.POST)
if form.is_valid():
user = form.save()
update_session_auth_hash(request, user)
messages.success(
request, "Your password has been successfully updated")
return redirect(request.META.get('HTTP_REFERER'))

On Tue, Nov 5, 2024 at 10:30 PM cseb...@gmail.com <cseb...@gmail.com> wrote:
When I change a password, users are logged out.
Django recommends keeping users logged in
by calling django.contrib.auth.update_session_auth_hash(request, user).

This is not working in a Django website of mine.
They must log in again!?

There are no error messages.  Is there any way I can provide
more details?

Chris

--
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...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/04908d1c-a1e4-41ea-afd8-e227f78af8bcn%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/0c0c2c50-5064-4e9d-a579-f0ddb323c11an%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/CAPUD46tCgtE4bK6yrrZ18FuxE4oTsvkda%2BLG2S8Fz14pxrkb%3DA%40mail.gmail.com.

Re: django.contrib.auth.update_session_auth_hash not working after change password

Ruby

Thank you very much.  Here is my code...


INV        = grandmas4hire.models.Invitation  

...

def add_url_param(url, param, arg):                                             
        prefix = "&" if "?" in url else "/?"                                    
                                                                                
        return url + prefix + f'{param}={str(arg).replace(" ", "+")}'           
 
---

@django.contrib.auth.decorators.login_required                                  
def change_password(request):                                                  
        user = request.user                                                    
        msg  = request.GET.get("msg")                                          
        if request.method == "POST":                                            
                form = grandmas4hire.forms.ChangePasswordForm(request.POST)    
                if form.is_valid():                                            
                        new_password = form.cleaned_data["new_password"]        
                        inv          = INV.objects.get(user = user)            
                        inv.user.set_password(new_password)                    
                        inv.user.save()                                        
                        django.contrib.auth.update_session_auth_hash(request,  
                                                                     user)      
                        url          = add_url_param("/change_password",        
                                                     "msg",                    
                                                     "Password+changed.")      
                        reply        = django.shortcuts.redirect(url)          
                else:                                                          
                        reply = django.shortcuts.render(request,                
                                                        "change_password.html",
                                                        {"form" : form})        
        else:                                                                  
                form  = grandmas4hire.forms.ChangePasswordForm()                
                reply = django.shortcuts.render(request,                        
                                                "change_password.html",        
                                                {"form" : form,                
                                                 "msg"  : msg})                
                                                                               
        return reply                          

On Tuesday, November 5, 2024 at 5:41:09 PM UTC-6 Ruby wrote:
How was it implemented?
Show a snippet from your code
See how it was used in my code

form = ChangePasswordForm(request, request.POST)
if form.is_valid():
user = form.save()
update_session_auth_hash(request, user)
messages.success(
request, "Your password has been successfully updated")
return redirect(request.META.get('HTTP_REFERER'))

On Tue, Nov 5, 2024 at 10:30 PM cseb...@gmail.com <cseb...@gmail.com> wrote:
When I change a password, users are logged out.
Django recommends keeping users logged in
by calling django.contrib.auth.update_session_auth_hash(request, user).

This is not working in a Django website of mine.
They must log in again!?

There are no error messages.  Is there any way I can provide
more details?

Chris

--
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...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/04908d1c-a1e4-41ea-afd8-e227f78af8bcn%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/0c0c2c50-5064-4e9d-a579-f0ddb323c11an%40googlegroups.com.

Tuesday, November 5, 2024

Re: django.contrib.auth.update_session_auth_hash not working after change password

How was it implemented?
Show a snippet from your code
See how it was used in my code

form = ChangePasswordForm(request, request.POST)
if form.is_valid():
user = form.save()
update_session_auth_hash(request, user)
messages.success(
request, "Your password has been successfully updated")
return redirect(request.META.get('HTTP_REFERER'))

On Tue, Nov 5, 2024 at 10:30 PM cseb...@gmail.com <cseberino@gmail.com> wrote:
When I change a password, users are logged out.
Django recommends keeping users logged in
by calling django.contrib.auth.update_session_auth_hash(request, user).

This is not working in a Django website of mine.
They must log in again!?

There are no error messages.  Is there any way I can provide
more details?

Chris

--
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+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/04908d1c-a1e4-41ea-afd8-e227f78af8bcn%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/CAPUD46vsy1FftCrZAarqSKC_Y8Yx27nMqOfqzcwkkxQ6dG7HwQ%40mail.gmail.com.

django.contrib.auth.update_session_auth_hash not working after change password

When I change a password, users are logged out.
Django recommends keeping users logged in
by calling django.contrib.auth.update_session_auth_hash(request, user).

This is not working in a Django website of mine.
They must log in again!?

There are no error messages.  Is there any way I can provide
more details?

Chris

--
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+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/04908d1c-a1e4-41ea-afd8-e227f78af8bcn%40googlegroups.com.

Re: Help serving media files on render

Hello Sir,
Greetings from DRP IT Services.

🌹
We are providing various digital solutions on one platform ( IT - All Rounder ).
💐
We are experts in -

* Website ( Static and Dynamic )
* App (android/iOS)
* Search Engine Optimization ( on page / Off page )
* Search Engine Marketing Ads( google, youtube, Google business,Facebook, LinkedIn )  
* Product Based Ads ( Google, Flipkart, amazon)
* Email Marketing
* SMS Marketing
* Software Development
*  Social Media Management
* IT - All Rounder

💐💐
We wish to work with your esteemed organization.
Kindly give us an appointment so that our senior executive may meet you.

Thanks.
WhatsApp: +91-7054633323
URL - https://www.drpits.com/

On Tuesday, November 5, 2024 at 11:48:44 AM UTC+5:30 Adisa Habeebulah wrote:
I experienced this recently, try using Idrive 

On Fri, Nov 1, 2024, 1:41 PM ASAMOAH EMMANUEL <emmanuela...@gmail.com> wrote:
Hi All,
I need help serving media files on render. I already serve static files with whitenoise.
I am able to upload media files but cannot serve them. I get file not found.
If it is not possible, are there other alternatives to s3 bucket.
Thanks in advance.

--
I don't stop when I'm tired, I only stop when the job is done.

--
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...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/CABFHQYxovaK2h6S52LOy19uofRzMTAtobY4szMhmGjD2QaZddw%40mail.gmail.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/2fd1c89f-5a5f-4962-96b3-f57a825b7fafn%40googlegroups.com.

Monday, November 4, 2024

Re: Help serving media files on render

I experienced this recently, try using Idrive 

On Fri, Nov 1, 2024, 1:41 PM ASAMOAH EMMANUEL <emmanuelasamoah179@gmail.com> wrote:
Hi All,
I need help serving media files on render. I already serve static files with whitenoise.
I am able to upload media files but cannot serve them. I get file not found.
If it is not possible, are there other alternatives to s3 bucket.
Thanks in advance.

--
I don't stop when I'm tired, I only stop when the job is done.

--
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+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/CABFHQYxovaK2h6S52LOy19uofRzMTAtobY4szMhmGjD2QaZddw%40mail.gmail.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/CAF0%2B-3%3D8DHdKxbKXWVhFPyrsCMsfPKPg%2BQdU83ouRJbD-2D6Vg%40mail.gmail.com.