Forums

Newbie question about django/admin

Have problem with accessing ../admin on my page on pythonanywhere. If I use "path('admin/', admin.site.urls)" with trailing slash after "admin" in my urlpatterns, I can only access it typing trailing slash in browser address bar. But when I remove slash from "path('admin', admin.site.urls)" suddenly both options with and without trailing slash in address bar work. I never seen "path('admin', admin.site.urls)" without trailing slash so I presume this is not correct solution - how should it be done?

Also it is not clear for me what admin name and password is. I found in sqlite3 file there is only one user in my django database - my login name. But my login name + password wont work when trying log to django admin? When I try to create new superuser in bash (python3 manage.py createsuperuser), I am getting PosixPath error. These may be simple issues but I cant google any solutions?

Choose however you would like your URLs to work and use that version.

The admin username and password are the ones that you set when you created the super user using manage.py. Make sure that you are running manage.py in the environment (Python version/virtualenv) that you chose for your web app.

Gosh... How could I forget about "$ workon" ? Maybe because I always work on virtualenv without virtualenvwrapper? Thanks glenn, this was like one of these moments when you cant see obvious and need someone to point it with a finger ;) Also you say that my admin path is ok? Again I was wondering if I forgot some other way to set it. pythonanywhere is great environment to learn and I appreciate any help!

Happy to hear that -- glad we could help!