Having encountered this from a beginner perspective in the past, I'll go more in-depth -- first, a note on how to read the Django errors:
django.db.utils.OperationalError
means that there was an error in django’s database utility (the bits that connect up django to different types of DBs like MySQL, Postgres, and SQLite), hence the db.utils part. OperationalErrors are things that are returned from the database itself when you try to run something, which means that the you can isolate Django and focus on the database interaction itself. If Django didn’t exist and you ran the same commands through psql (postgres’ command line utility), you’d still see:
FATAL: role [username] does not exist
Also you generally can tell it’s an error from the database because of the all caps. Relational databases LOVE CAPS LOCK.
As far as solving it, the error is pretty self-descriptive. The thing you need to look at is your settings.py file (as kmmnbvnr pointed out). In your database configuration, you should see a username and password. Postgres is complaining that you are trying to connect to the configured DB with a user that doesn’t exist, so you need to create it. Here are the commands using PSQL instead of the sudo commands kmmbvnr used:
Connect to the database with the command line utility:
$ psql -d postgres
If you created a database that was not the default postgres, use that instead for the database name,
i.e. $ psql -d my_database_name
Edit: On certain OSs you may need to add a -U <database user> if it fills in your OS username and not the default "postgres" username.
i.e. $ psql -d postgres -U postgres (postgres is the default user).
CREATE ROLE testrole WITH LOGIN ENCRYPTED PASSWORD 'password';
ALTER ROLE testrole WITH CREATEDB;
grant all privileges on database postgres to testrole;
Change testrole and password to whatever you’d like, so long as they match the username/password in settings.py. Do note the ' ' around the password, but not around the username. Those are important. Also note that Postgres frowns upon using the builtin ‘postgres’ user for non-administrative tasks for security reasons, so it’s best to create another user to use with Django. Also, the last lines about granting permissions are a bit permissive, but for a local test configuration, it’ll be your easiest bet. Consult the Postgres docs on privileges for production environments / proper security.
Lastly, you can test, independent of django, by consulting the man page on PSQL (man psql on linux / mac) on how to login with a specific user with the command line. I believe the command is:
$ psql -d postgres -U testrole -W
Where the -d is specifying the database (i.e. mydatabase or postgres), the -U is the user to connect with, and the -W means prompt for a password.