Error while deleting user from django

And I am trying to delete this from superuser account

Deleting the user ‘user’ would result in deleting related objects, but your account doesn’t have permission to delete the following types of objects:

  • course enrollment

What command are you running to delete the user?

Are you using tutor local run lms ./manage.py lms manage_user --remove <username> <user_email>

To see a list of all available production commands you can run tutor local run lms ./manage.py lms --settings production help.

In the admin interface, it doesn’t let you do this for some reason (tutor specific config?).

But can confirm that @iammcgaber’s solution works.

EDIT: Some accounts allow me to delete them via the web admin. I deleted a normal account I made for testing purposes. Another test account didn’t work though. Perhaps it has to do with the “staff” flag on the account?

Either way the tutor command line works.

Hello, @iammcgaber solution works perfectly, by i have a user who has a username with “-” and i cannot delete him
tutor local run lms ./manage.py lms manage_user --remove -test123 test@yahoo.com
I’ve tried tutor local run lms ./manage.py lms manage_user --remove “-test123” test@yahoo.com
and single quotes too ’ and to conert it to ascii number
tutor local run lms ./manage.py lms manage_user --remove 045 115 116 097 049 050 051
Do you have any idea, what can i do?

Thank you in advance

Did you try just escaping the dash? "\-test123"?

yes

tutor local run lms ./manage.py lms manage_user --remove “\-elshf” kyrgianniskebap@gmail.com
Error: Command failed with status 1: docker-compose -f /root/.local/share/tutor/env/local/docker-compose.yml -f /root/.local/share/tutor/env/local/docker-compose.prod.yml --project-name tutor_local run --rm lms ./manage.py lms mana ge_user --remove “-elshf” kyrgianniskebap@gmail.com

I’ve tried everything and nothing works
-name “email”
“-name” “email”
tutor local run lms ./manage.py lms manage_user --remove “-name” “email”
/-name email
tutor local run lms ./manage.py lms manage_user --remove – -name mail
but it not reeds the mail.

I was thinking is there a tutor command in order to rename the username in order to remove “-” and then delete it with your command?

Thank you in advance

Hello, same problem for me.

django.db.utils.IntegrityError: (1451, ‘Cannot delete or update a parent row: a foreign key constraint fails (openedx.course_creators_coursecreator, CONSTRAINT course_creators_coursecreator_user_id_e4da548d_fk_auth_user_id FOREIGN KEY (user_id) REFERENCES auth_user (id))’)

Whole error message link here: ~$ tutor local run lms ./manage.py lms manage_user --remove username user@email.cz
I have tried to set user in studio “/admin/course_creators/coursecreator/” all states (unrequested/pending/granted/denied) with same error when tried to delete.
Tutor version “13.1.7”

edit: User is created via SAML.