Closed nro-bot closed 3 years ago
I have circumvented by creating a new user via the browser, then setting is_staff
to true in the database, (UPDATE auth_user SET is_superuser = 't' WHERE id=2;
) but I am guessing there is some default I'm missing? -- would be great to add to docs ^^
Good call. Sorry again about that, glad you found a workaround. I'll probably just include the default in the docs, but know for the future that you can also use the "createsuperuser" command (https://docs.djangoproject.com/en/3.1/ref/django-admin/#createsuperuser) in a similar manner to the other two commands you just ran.
Also if you don't mind I'm gonna keep this open for a bit as a reminder to update the docs when I have a moment.
Yes of course, thanks for creating this! I can contrib to docs when I have a chance, in the meantime here are some notes for the workaround which I have tried to be fairly detailed:
To create user: First
$ docker-compose up` # should see one of lines is as follows
[...]
Starting puzzlehunt_server_db_1 ... done
[...]
Second go to http://localhost/accounts/create/ & complete form.
Third give superuser permissions. Begin by logging into database.
docker exec -it puzzlehunt_server_db_1 psql -U user -W puzzlehunt_db
Note that after the after -U and -W is what you have put in .env
eg DB_NAME=puzzlehunt_db
, and DB_USER=user
are the defaults.
After press enter, will prompt for password - put what you have in DB_PASSWORD
Meanwhile, the puzzlehunt_server_db_1
is a container started up by docker-compose
(I think).
Next update user.
puzzlehunt_db=# \dt` will list tables.
puzzlehunt_db=# \ UPDATE auth_user SET is_superuser = 't' WHERE id=2;`
Note semicolon! If you want to check if you're giving to correct user
SELECT * FROM auth_user;
That is all, now you can login at localhost
and should be able to edit hunts etc.
Note: You may verify docker container puzzlehunt_server_db_1
is running with
docker container ls
(or tab-complete may help)
django-admin createsuperuser
is definitely a useful command to know! Though, the default clone/setup does not install django-admin and I had some difficulty figuring out how to get it to work with docker-exec. I will investigate a proper python setup in future.
Thanks for the writeup of what you've done, it is good to have a well documented backup solution.
This is the part where I admit I don't know why the container doesn't have django-admin. I do know though that the manage.py file is the same as django-admin ( https://docs.djangoproject.com/en/3.1/ref/django-admin/ ) . This isn't something of my own doing, a blank django project will have a manage.py with all the features of django-admin. Either way, this is why the commands I gave you previously started with docker-compose exec app python3 /code/manage.py
as it stands in for django-admin. Anyway, something along the lines of docker-compose exec app python3 /code/manage.py createsuperuser {{arguments_to_createsuperuser}}
should work in the future and is what I will likely document.
Oh, nah you're right it does exist! I was using docker exec
instead of docker-compose exec
. So, my backup solution (and the documentation RIP) is not needed! I'm definitely less familiar with docker than you :)
p.s. two other notes (maybe this issue name should be documentation updates?) which I'll jot in less full than above which turned out to be a waste of time ...
0
. Then go to staff page, maangement, release initial puzzlesClosing this as the step for creating an admin user has been added to docs on dev branch to be released next version. The helpful items from the last comment will be copied into a new issue.
linking for my ref via https://github.com/dlareau/puzzlehunt_server/issues/160
I have just done new docker setup, cannot log in to staff page. I see the default root user is "hunt" but not sure password ?