0

I'm new to Wagtail and django. I've completed the https://learnwagtail.com/wagtail-for-beginners/ course and managed to get my site up and running on Digital ocean, however I'm unable to login to the admin area. I have tried using the superuser credentials that were used locally. I have also tried multiple times to create a new superuser with:

python manage.py createsuperuser

and while the process appears to work successfully in the terminal (I'm logged in via SSH to my DO droplet), I continually receive the 'Your username and password didn't match. Please try again.' message when attempting to log in with the newly created username and password. If I use the shell to check users I can see my newly created user exists. I have also tried using

python manage.py changepassword myusername

to change the password on the previously created superusers, but again, while the process appears to work successfully in the terminal I continue to receive the error message when attempting to log in. Can anyone point me in the right direction as to what I might be missing or doing wrong here? And / or how I might best debug the issue? Thanks in advance!

SilentDesigns
  • 505
  • 2
  • 7
  • 22

2 Answers2

1

You might need to set up a Site that matches the domain on which you're accessing your site. In the command line, try this:

import wagtail.core.models.sites
s=Site.objects.last()
s.hostname='yourdomain'
s.site_name='verbose site name'
s.is_default_site=True
s.save()

If you don't already have a site in the database (or just want to add another one), then do s=Site.objects.create() instead of Site.objects.last()place the three properties into thecreate` statement as keywords.

Dan Swain
  • 2,910
  • 1
  • 16
  • 36
  • Thanks, I didn't have a site created so followed these instructions, but it didn't solve my issue. I did find a solution though which I will add as an answer. – SilentDesigns Jan 25 '22 at 01:29
0

I needed to make sure my manage.py commands were picking up my production settings. So running: DJANGO_SETTINGS_MODULE=mysite.settings.production ./manage.py createsuperuser

and NOT: python manage.py createsuperuser was the solution.

SilentDesigns
  • 505
  • 2
  • 7
  • 22