Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions config/docker-compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"ENGINE": "django.db.backends.postgresql",
"NAME": os.environ.get("POSTGRES_DB", "pokeapi"),
"USER": os.environ.get("POSTGRES_USER", "ash"),
"PASSWORD": os.environ.get("POSTGRES_PASSWORD", "pokemon"),
Expand All @@ -23,6 +23,4 @@
}
}

DEBUG = False

ALLOWED_HOSTS = ["*"]
2 changes: 1 addition & 1 deletion config/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"ENGINE": "django.db.backends.postgresql",
"NAME": "pokeapi",
"USER": "ash",
"PASSWORD": "pokemon",
Expand Down
2 changes: 1 addition & 1 deletion config/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(PROJECT_ROOT, "db.sqlite3"),
"NAME": BASE_DIR / "db.sqlite3",
}
}

Expand Down
28 changes: 9 additions & 19 deletions config/settings.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
# Production settings
import os
from unipath import Path
from pathlib import Path

PROJECT_ROOT = Path(__file__).ancestor(2)
BASE_DIR = Path(__file__).resolve().parent.parent

DEBUG = False

TEMPLATE_DEBUG = DEBUG

ADMINS = (
os.environ.get("ADMINS", "Paul Hallett,paulandrewhallett@gmail.com").split(","),
)
ADMINS = (os.environ.get("ADMINS", "admin,admin@noemail.com").split(","),)

EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

MANAGERS = ADMINS

BASE_URL = os.environ.get("BASE_URL", "http://pokeapi.co")

# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = [
os.environ.get("ALLOWED_HOSTS", ".pokeapi.co"),
"localhost",
"127.0.0.1",
]

TIME_ZONE = os.environ.get("TIME_ZONE", "Europe/London")
TIME_ZONE = os.environ.get("TIME_ZONE", "UTC")

LANGUAGE_CODE = os.environ.get("LANGUAGE_CODE", "en-gb")
LANGUAGE_CODE = os.environ.get("LANGUAGE_CODE", "en-us")

SITE_ID = 1

Expand Down Expand Up @@ -82,28 +78,23 @@
}

SECRET_KEY = os.environ.get(
"SECRET_KEY", "ubx+22!jbo(^x2_scm-o$*py3e@-awu-n^hipkm%2l$sw$&2l#"
"SECRET_KEY", "django-insecure-a(!_5+l3$#l1f4n!x+&ns_+8$4q@df*3rh$n#2h@l$2gti7!7-"
)

CUSTOM_APPS = ("pokemon_v2",)

INSTALLED_APPS = (
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.sites",
"django.contrib.admin",
"django.contrib.messages",
"django.contrib.humanize",
"corsheaders",
"rest_framework",
"cachalot",
"drf_spectacular",
) + CUSTOM_APPS


API_LIMIT_PER_PAGE = 1

CORS_ORIGIN_ALLOW_ALL = True

CORS_ALLOW_METHODS = "GET"
Expand All @@ -127,7 +118,6 @@
"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",
Expand All @@ -136,7 +126,7 @@
},
]

DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

SPECTACULAR_SETTINGS = {
"TITLE": "PokéAPI",
Expand All @@ -154,7 +144,7 @@

This API will always be publicly available and will never require any extensive setup process to consume.

Created by [**Paul Hallett**](https://github.com/phalt) and other [**PokéAPI contributors***](https://github.com/PokeAPI/pokeapi#contributing) around the world. Pokémon and Pokémon character names are trademarks of Nintendo.
Created by [**Paul Hallett**](https://github.com/phalt) and other [**PokéAPI contributors**](https://github.com/PokeAPI/pokeapi#contributing) around the world. Pokémon and Pokémon character names are trademarks of Nintendo.
""",
"SORT_OPERATIONS": False,
"SERVERS": [{"url": "https://pokeapi.co"}],
Expand Down
27 changes: 5 additions & 22 deletions config/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,16 @@
"""
WSGI config for project.
WSGI config for mysite project.

This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.

Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
that later delegates to the Django one. For example, you could introduce WSGI
middleware here, or combine a Django application with an application of another
framework.
It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
# if running multiple sites in the same mod_wsgi process. To fix this, use
# mod_wsgi daemon mode with each site in its own daemon process, or use
# os.environ["DJANGO_SETTINGS_MODULE"] = ".settings"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
application = get_wsgi_application()

# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)
19 changes: 16 additions & 3 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""

import os
import sys

if __name__ == "__main__":

def main():
"""Run administrative tasks."""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
if __name__ == "__main__":
main()
5 changes: 1 addition & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
Django==4.2.27
Unipath==1.1
Django==5.2.10
coverage==7.13.1
django-cors-headers==4.9.0
django-redis==6.0.0
django-cachalot==2.8.0
djangorestframework==3.16.1
gunicorn==23.0.0
psycopg[binary]==3.3.2
python-dateutil==2.9.0
python-mimeparse==2.0.0
drf-spectacular==0.29.0
legacy-cgi; python_version >= '3.13'