Skip to content

Commit 0733cc8

Browse files
authored
Merge pull request #58 from AyushDharDubey/fix-make_admin-cmnd-to-update-the-full-user-model
Fix: make_admin command - save `profile` instance instead of `user`
2 parents 9ab80af + 8b01a72 commit 0733cc8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mainapp/management/commands/make_admin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ def handle(self, *args, **options):
7474
if dismiss:
7575
if user.profile.is_admin:
7676
user.profile.is_admin = False
77-
updated_fields.append('profile__is_admin')
77+
updated_fields.append('is_admin')
7878
else:
7979
if not user.profile.is_admin:
8080
user.profile.is_admin = True
81-
updated_fields.append('profile__is_admin')
81+
updated_fields.append('is_admin')
8282

8383
if updated_fields:
84-
user.save(update_fields=updated_fields)
84+
user.profile.save(update_fields=updated_fields)
8585
action = "dismissed from admin" if dismiss else "made admin"
8686
logger.info(
8787
f"Successfully {action} for user '{user.username}'. "

0 commit comments

Comments
 (0)