Related
Sorry but I don't know what is happening when I try to run (python3 manage.py makemigrations).
I really don't know what's going on I'm looking for an answer for a while but I can't figure out where the error is:
(paginas) root#janstar:/home/paginas/proyectodedjango# python3 manage.py makemigrations
Traceback (most recent call last):
File "/home/paginas/lib/python3.6/site-packages/django/core/management/base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/paginas/lib/python3.6/site-packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/home/paginas/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/home/paginas/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py", line 101, in handle
loader.check_consistent_history(connection)
File "/home/paginas/lib/python3.6/site-packages/django/db/migrations/loader.py", line 283, in check_consistent_history
applied = recorder.applied_migrations()
File "/home/paginas/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 76, in applied_migrations
if self.has_table():
File "/home/paginas/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 56, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "/home/paginas/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/paginas/lib/python3.6/site-packages/django/db/backends/base/base.py", line 260, in cursor
return self._cursor()
File "/home/paginas/lib/python3.6/site-packages/django/db/backends/base/base.py", line 236, in _cursor
self.ensure_connection()
File "/home/paginas/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/paginas/lib/python3.6/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection
self.connect()
File "/home/paginas/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/paginas/lib/python3.6/site-packages/django/db/backends/base/base.py", line 197, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/paginas/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/paginas/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 199, in get_new_connection
conn = Database.connect(**conn_params)
TypeError: argument 1 must be str, not PosixPath
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/paginas/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/paginas/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/paginas/lib/python3.6/site-packages/django/core/management/base.py", line 341, in run_from_argv
connections.close_all()
File "/home/paginas/lib/python3.6/site-packages/django/db/utils.py", line 230, in close_all
connection.close()
File "/home/paginas/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/paginas/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 261, in close
if not self.is_in_memory_db():
File "/home/paginas/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 380, in is_in_memory_db
return self.creation.is_in_memory_db(self.settings_dict['NAME'])
File "/home/paginas/lib/python3.6/site-packages/django/db/backends/sqlite3/creation.py", line 12, in is_in_memory_db
return database_name == ':memory:' or 'mode=memory' in database_name
TypeError: argument of type 'PosixPath' is not iterable
Try changing this:
For this:
Sorry if I added the images wrong I'm new to this page.
This is my settings.py file:
"""
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-k3d35^_5m3-=t-7&-!4qq78o+h%-ra6atz-a9m1)19a7()$8u2'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ['31.220.48.123']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'ckeditor',
'mainapp',
'pages.apps.PagesConfig',
'blog.apps.BlogConfig',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'ProyectoDjango.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'pages.context_processors.get_pages',
'blog.processor.get_categories',
],
},
},
]
WSGI_APPLICATION = 'ProyectoDjango.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
"""
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
"""
"""
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'proyectodjango',
'USER': 'root',
'PASSWORD': '12345',
'HOST': 'localhost',
'PORT': 3306
}
}
"""
# Password validation
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/
LANGUAGE_CODE = 'es-es'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# Media
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
"""
and this is my manage.py file:
enter image description here
In the error message it says that you need a string instead of 'PosixPath' try turning the path into a string.
You can also use:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
Simply you can try this way:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
After adding above code in settings.py file, first you need to delete db file and delete all migration folders of each app and then run below commands:
python manage.py makemigrations appname
python manage.py sqlmigrate appname 0001
python manage.py migrate
And now your problem will solve.
When I run this python manage.py migrate
return Connection(*args, **kwargs)
File "C:\Users\WyndhamKeitA\AppData\Roaming\Python\Python310\site-packages\MySQLdb\connections.py", line 185, in __init__
super().__init__(*args, **kwargs2)
**TypeError: connect() argument 4 must be str, not WindowsPath**
my DB under settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': BASE_DIR / 'db.crudpy',
'USERNAME': 'root',
'PASSWORD': '1234',
'PORT': '3306',
'HOST': 'localhost'
}
}
How do I get rid of the error?
crudpy is the schema I've created on mysql
The app I've been working on, which uses Python 3.9, Flask 2.0.2, peewee 3.14.4, and MySQL 8.0 works fine, except when I add configuration options for the FlaskDB dictionary of configuration options. I need to add MySQL configuration options (including SSL) when I deploy the app.
The FlaskDB configuration options which do work
DATABASE = {
'name': DB_NAME,
'engine': 'peewee.MySQLDatabase',
'user': DB_USERNAME,
'passwd': DB_PASSWORD,
'host': DB_HOST,
'port': DB_PORT}
The FlaskDB configuration options which do NOT work
DATABASE = {
'name': DB_NAME,
'engine': 'peewee.MySQLDatabase',
'user': DB_USERNAME,
'passwd': DB_PASSWORD,
'host': DB_HOST,
'port': DB_PORT,
'max_connections': 32,
'stale_timeout': 300}
The error I receive from the uwsgi log
Traceback (most recent call last):
File "/app/./wsgi.py", line 4, in <module>
from run import app
File "/app/./run.py", line 6, in <module>
app = create_app()
File "/app/./ticketsapi/__init__.py", line 33, in create_app
from ticketsapi.users.routes import users
File "/app/./ticketsapi/users/routes.py", line 8, in <module>
from ticketsapi.models import User, Post
File "/app/./ticketsapi/models.py", line 302, in <module>
initalisedB()
File "/app/./ticketsapi/models.py", line 233, in initalisedB
if User.table_exists():
File "/app/venv/lib/python3.9/site-packages/peewee.py", line 6658, in table_exists
return cls._schema.database.table_exists(M.table.__name__, M.schema)
File "/app/venv/lib/python3.9/site-packages/peewee.py", line 3310, in table_exists
return table_name in self.get_tables(schema=schema)
File "/app/venv/lib/python3.9/site-packages/peewee.py", line 4011, in get_tables
return [table for table, in self.execute_sql(query, ('VIEW',))]
File "/app/venv/lib/python3.9/site-packages/peewee.py", line 3142, in execute_sql
cursor = self.cursor(commit)
File "/app/venv/lib/python3.9/site-packages/peewee.py", line 3126, in cursor
self.connect()
File "/app/venv/lib/python3.9/site-packages/peewee.py", line 3080, in connect
self._state.set_connection(self._connect())
File "/app/venv/lib/python3.9/site-packages/peewee.py", line 3982, in _connect
conn = mysql.connect(db=self.database, **self.connect_params)
TypeError: __init__() got an unexpected keyword argument 'max_connections'
Looking at page 287 of the peewee Documentation, Release 3.14.4 my syntax looks to be valid. From the peewee documentation:
DATABASE = {
'name': 'my_app_db',
'engine': 'playhouse.pool.PooledPostgresqlDatabase',
'user': 'postgres',
'max_connections': 32,
'stale_timeout': 600,
}
Any thoughts on where I'm going wrong?
The obvious answer, I needed to add playhouse.pool.PooledMySQLDatabase to the configuration options:
DATABASE = {
'name': DB_NAME,
'engine': 'playhouse.pool.PooledMySQLDatabase',
'user': DB_USERNAME,
'passwd': DB_PASSWORD,
'host': DB_HOST,
'port': DB_PORT,
'max_connections': 32,
'stale_timeout': 300}
I am currently trying to deploy my Django project on to a free Heroku server. When I try to execute the following command I get an error heroku run python3 manage.py migrate.
The error is as follows:
Running python3 manage.py makemigrations on ⬢ samstaskmanager... up, run.5214 (Free)
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 187, in get_new_connection
connection = Database.connect(**conn_params)
File "/app/.heroku/python/lib/python3.6/site-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 85, in wrapped
res = handle_func(*args, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py", line 101, in handle
loader.check_consistent_history(connection)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/loader.py", line 290, in check_consistent_history
applied = recorder.applied_migrations()
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 77, in applied_migrations
if self.has_table():
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 55, in has_table
with self.connection.cursor() as cursor:
File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/base.py", line 259, in cursor
return self._cursor()
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/base.py", line 235, in _cursor
self.ensure_connection()
File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 187, in get_new_connection
connection = Database.connect(**conn_params)
File "/app/.heroku/python/lib/python3.6/site-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
This is my settings.py:
Django settings for app project.
Generated by 'django-admin startproject' using Django 3.1.1.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
from pathlib import Path
import os
#import django_heroku
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'x0)a5try9uyd+t_l-5x#1*yfu#-$-(u665rz5#_m!!t5b7&d(6'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [
'taskmanager.apps.TaskmanagerConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'app.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR,'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'app.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'taskmanager',
'USER': 'postgres',
'PASSWORD': 'sam3778987',
'HOST': 'localhost'
}
}
# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
# Activate Django-Heroku.
#django_heroku.settings(locals())
I am really not sure why I keep getting this error so any help would be appreciated. Also sorry about the messy question it is my first time writing one.
Looks to me like you are trying to use a PostgreSQL database on your local machine with your app hosted on Heroku.
I use a PostgreSQL database on a recently created app. I eventually created two settings.py files (with different names, obviously). One is what I use when I run the app locally. It has the following code for the database connection:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': DB_NAME,
'USER': MY_USERNAME,
'PASSWORD': MY_PASSWORD,
'HOST': HOST,
'PORT': '5432',
}
}
In my production settings.py (which I call settings_heroku_deploy.py and use in my Procfile during deployment) I have the following:
import dj_database_url
DATABASES = {}
DATABASES['default'] = dj_database_url.config(conn_max_age=600)
DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql'
You probably know this already, but one of the characteristics of a PostgreSQL database is that it's hosted on a server. So the server you use needs to be available wherever you happen to run your application. I chose to configure a PostgreSQL database as an addon in Heroku. During deployment I use the dj_database_url package to automatically configure my connection, whereas on my local machine I have to explicitly provide username, password, etc.
Even if you can get your app to connect to your local database it's definitely worth making the switch a Heroku PostgreSQL database. It's free to start and certainly more flexible than hosting something locally (unless you have an actual server at your disposal).
It's due to your Postgres database.you can find it in the settings.py. change the host and port setting. maybe you have blank the host and port section. Let me know if it helps you.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'taskmanager',
'USER': 'postgres',
'PASSWORD': 'sam3778987',
'HOST': 'localhost',
'PORT': '5432',
}
}
edit: Thanks for sharing your settings.py code.
Let me know if it helps you.
I am currently playing with django and want to use as my database postgresql:
and these are my configurations in my settings file:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'django', # Or path to database file if using sqlite3.
'USER': 'postgres', # Not used with sqlite3.
'PASSWORD': 'postgres', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '5432', # Set to empty string for default. Not used with sqlite3.
}
}
I also tried it with postgresql_psycopg2 and also installed psycopg2(http://www.stickpeople.com/projects/python/win-psycopg/).
Any ideas whats wrong with the configurations?
UPDATE:
The Error:
> File
> "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 382, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python27\lib\site-packages\django\core\management\base.py", line
> 196, in run_from_argv
> self.execute(*args, **options.__dict__) File "C:\Python27\lib\site-packages\django\core\management\base.py", line
> 232, in execute
> output = self.handle(*args, **options) File "C:\Python27\lib\site-packages\django\core\management\base.py", line
> 371, in handle
> return self.handle_noargs(**options) File "C:\Python27\lib\site-packages\django\core\management\commands\syncdb.py",
> line 57, in handle_noargs
> cursor = connection.cursor() File "C:\Python27\lib\site-packages\django\db\backends\dummy\base.py", line
> 15, in complain
> raise ImproperlyConfigured("settings.DATABASES is improperly configured. " django.core.exceptions.ImproperlyConfigured:
> settings.DATABASES is improperly configured. Please supply the ENGINE
> value. Check settings documentation for more details.
This is an old question but I am adding an answer for future visitors. You seem to have several errors:
If you already installed psycopg2, you should change the ENGINE name to django.db.backends.postgresql_psycopg2.
In your settings you specified your database NAME to be django, but in your pgAdmin screenshot it is seen that you don't have such a database. Create a database named django using pgAdmin.
The correct setup would be then:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django',
'USER': 'postgres',
'PASSWORD': 'postgres',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}