I have a simple website where users can register in order to have access to private content and to receive a newsletter. I have used django-registration for user registration and authentication, and used some HTML templates from here.
The whole system is working (login, logout, password recovery, etc.) but I realized that user cannot delete their account from the website. Is there a plugin designed for this, or how to extend the registration classes to do that? By deleting, I'd prefer a real suppression, not just making the user inactive.
You can do something like this:
And have a url pattern like:
This will do the work. It will delete a user by given username.
But, as the docs say:
It is a better approach to set the user as inactive instead of deleting it totally from the database, because the foreign keys will break.
So you can simply do:
And as now everyone can access this view, you must add some permissions. A straightforward approach will be to override the built-in
@user_passes_test
decorator: