Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document use of management command for initial admin user setup #4733

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

mikerkelly
Copy link
Contributor

This command is simpler than a DB shell and helps new developers get familiar with a useful tool. I’ve used the -s switch instead of --staff-area-administrator for ease of typing and memorability. Once familiar with the short form, developers may not need to refer back to these docs.

This command is simpler than a DB shell and helps new developers get familiar
with a useful tool. I’ve used the -s switch instead of
--staff-area-administrator for ease of typing and memorability. Once familiar
with the short form, developers may not need to refer back to these docs.
@mikerkelly mikerkelly self-assigned this Nov 11, 2024
Copy link
Member

@iaindillingham iaindillingham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot! IIRC Steve proposed an admin command for adding this role to a user in #4552, but we decided against it.

>>> user = User.objects.get(username="<your_username>")
>>> user.roles.append(StaffAreaAdministrator)
>>> user.save()
> python manage.py create_user <your_username> -s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: As the rationale for this change is to support a new developer, then I'd suggest using the long-form of the argument (--staff-area-administrator) to make it absolutely clear what type of user create_user is creating.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's clear from the preceding line that explains the purpose of running the command.

I’ve used the -s switch instead of --staff-area-administrator for ease of typing and memorability. Once familiar
with the short form, developers may not need to refer back to these docs.

Copy link
Contributor Author

@mikerkelly mikerkelly Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC Steve proposed an admin command for adding this role to a user in #4552, but we decided against it.

It's been there since the command was added in #4096 for Airlock purposes. It's definitely easy to overlook -- at one point I started writing one myself until I realized create_user can also do updates. I might have called it create_or_update_user, though that's a bit of a mouthful. But no less convenient if you have manage.py autocomplete on, and probably less confusing. Hmm.

I support having Create-Update and Delete management commands for models that developers commonly manage locally. More convenient that writing SQL queries, for me at least. Automating common development tasks is useful, and adding or removing admin to myself is something I do all the time.

@mikerkelly mikerkelly merged commit 6ffefe7 into main Nov 11, 2024
7 checks passed
@mikerkelly mikerkelly deleted the mikerkelly/docs/getting-started-admin-user branch November 11, 2024 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants