Unable to delete user in Django admin

I tried to delete a user in the Django admin panel and got an error that my user (Django admin) cannot delete the outstanding token of the user to be deleted. There is a list of outstanding token and I can see the user to be deleted has one. Is this is known issue? A limitation? Any workaround?

Thanks in advance

Hi there!

It is a known feature of Django, it stops you from deleting objects that are linked by mistake.

The best way to this is ask the user to remove the user themselves. Alternatively, if that is not possible, you can use the django shell, get the user object you are trying to delete by id, and then calling the cancel method of that user object.

Lastly, if none of the above is possible, you can override the password of that user from the Django Admin, and then log in as that user and delete the user as they would.

Best regards!

Hi @yannbourdeau

to keep the outstanding token list clean, you can use a command from your terminal.

./manage.py flushexpiredtokens

You can add

FLUSH_REFRESHED_TOKENS_PERIODICITY = True

to your taiga-back settings to remove expired tokens every 3 days (using a celery periodic tasks).

Or you can add the command to the cron table to run it periodically too.

Hi Charlie and David,

Charlie: the self registered user are not created as super admin( with taiga-manage.sh) so they cannot login to the Django admin panel. I noticed that I need to create the user with createsuperuser(if there is a way to upgrade a registered user to an superuser I’d like to know)

David: Thanks for the info. I tried it and I was not able to delete the user but I noticed the outstanding token will expire on may 9th. So I’ll retry after this date.
I have use taiga-manage.sh (not manage.py) to remove the expired tokens because I’m running Taiga in Docker.

Thanks both of you

Hi again!

The user can perform the deletion without going to the Django-admin. They need to go to their profile from Taiga and then click on Delete taiga account.

image

Hope this helps!

Best regards!

1 Like