Skip to content

How to Set Your User as Staff or Superuser

Wesley B edited this page May 17, 2023 · 6 revisions

Some tasks require a developer to have a user with staff-level permissions.

Use Cases

  • Test Onboarding as an admin (at URL /workbench/onboarding/admin).

Steps

  1. Completely shut down all of your containers and restart them.

  2. Login to docker shell:

    docker exec -it core_portal_django /bin/bash
    
  3. Enter python shell:

    python manage.py shell
    
  4. Find & Update your user:

    from django.contrib.auth import get_user_model
    my_user = get_user_model().objects.get(username="my_username")
    # Set your local user to be "staff" or "superuser"
    my_user.is_staff = True
    my_user.is_superuser = True
    my_user.save()
    
  5. (If needed) Inspect SetupEvents to view logs

    from portal.apps.onboarding.models import SetupEvent
    # Get your user model (change "my_username" to your username)
    # Inspect your user setup events, if things go wrong and we need additional debugging data
    events = SetupEvent.objects.all().filter(user=my_user)
    print(events)
    

Related

Clone this wiki locally