need to create database for user and need to add id column in database.

On Tuesday, December 27, 2022 at 11:32:11 PM UTC+5:30 Manjusha wrote:

> User object doesn't have attribute id so it will not work, I have checked 
> now and you can refer this documentation 
> <https://docs.djangoproject.com/en/4.1/topics/auth/default/>, so you will 
> get clear idea.
>
> On Monday, December 26, 2022 at 8:10:35 PM UTC+5:30 [email protected] 
> wrote:
>
>> Hey, 
>>
>> Here is what you can do:
>> When User clicks the Delete profile button you use Javascript Confirm 
>> then if they press OK you go to the view.
>>
>> def delete_account(request):
>>     user = User.objects.get(id=request.user.id)
>>     # You first logout the user then delete the account
>>     logout(request)
>>     # You can use either of these
>>     # To Soft Delete
>>     user.active = False
>>     user.save()
>>     # To Hard Delete
>>     user.delete()
>>     messages.success("You account has been deleted Successfully!")
>>     return redirect('home')
>>
>>
>> Let me know if this doesn't work.
>> -Raj Mandaviya
>>  
>>
>>
>> On Saturday, December 24, 2022 at 7:43:09 PM UTC+5:30 
>> [email protected] wrote:
>>
>>> Hi, I have created authentication system in Django. Anyone just tell me 
>>> how to allow user to delete the created profile with default id of the 
>>> user.[image: 
>>> Screenshot 2022-12-24 193133.png]. I I am using built-in  User 
>>> authentication libraries for this purpose and haven't created database 
>>> model for the user. But the function (the commented function under 
>>> delete_account) that I have created it is not deleting the user.
>>> Now I am trying to delete user profile using generic editing views  of 
>>> Django.
>>> Anyone tell me how to allow user to delete the created profile with 
>>> default id of the user.
>>>
>>

-- 
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/80645ba8-15e1-4856-8c24-8aac09a643bdn%40googlegroups.com.

Reply via email to