Skip to content

Commit

Permalink
updates demo 31 to latest versions
Browse files Browse the repository at this point in the history
  • Loading branch information
JB-Tellez committed Feb 19, 2024
1 parent 2432ea6 commit 604898a
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 75 deletions.
4 changes: 4 additions & 0 deletions class-31/demo/things-api/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# .dockerignore
.venv
.git
.gitignore
17 changes: 17 additions & 0 deletions class-31/demo/things-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Pull base image
FROM python:3.11.5-slim-bullseye

# Set environment variables
ENV PIP_DISABLE_PIP_VERSION_CHECK 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set work directory
WORKDIR /code

# Install dependencies
COPY ./requirements.txt .
RUN pip install -r requirements.txt

# Copy project
COPY . .
Binary file modified class-31/demo/things-api/db.sqlite3
Binary file not shown.
8 changes: 8 additions & 0 deletions class-31/demo/things-api/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
web:
build: .
ports:
- "8000:8000"
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
18 changes: 5 additions & 13 deletions class-31/demo/things-api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
asgiref==3.5.0
click==8.0.4
Django==4.0.3
djangorestframework==3.13.1
mccabe==0.6.1
mypy-extensions==0.4.3
pathspec==0.9.0
platformdirs==2.5.1
pycodestyle==2.8.0
pyflakes==2.4.0
pytz==2021.3
sqlparse==0.4.2
tomli==2.0.1
asgiref==3.7.2
Django==5.0.2
djangorestframework==3.14.0
pytz==2024.1
sqlparse==0.4.4
4 changes: 2 additions & 2 deletions class-31/demo/things-api/things/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generated by Django 4.0.3 on 2022-03-03 23:09
# Generated by Django 5.0.2 on 2024-02-17 16:54

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion class-31/demo/things-api/things_api_project/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/
"""

import os
Expand Down
106 changes: 51 additions & 55 deletions class-31/demo/things-api/things_api_project/settings.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
Django settings for things_api_project project.
Generated by 'django-admin startproject' using Django 4.0.3.
Generated by 'django-admin startproject' using Django 5.0.2.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/
https://docs.djangoproject.com/en/5.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
https://docs.djangoproject.com/en/5.0/ref/settings/
"""

from pathlib import Path
Expand All @@ -17,10 +17,10 @@


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-ke)sw__nz&hzvq42cl)w8t8zt%_g1-g_8!ur3#%4)@$t)s-(5t"
SECRET_KEY = 'django-insecure-y0hx8ys-r4d0qr9jw_a&^=*f%h2kkvs-avlav1%0lx1t1tqdn&'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand All @@ -31,103 +31,99 @@
# Application definition

INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
# third party
"rest_framework",
# local
"things",
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

# 3rd party
'rest_framework',

# in house
'things'
]

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",
'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 = "things_api_project.urls"
ROOT_URLCONF = 'things_api_project.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",
'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',
],
},
},
]

WSGI_APPLICATION = "things_api_project.wsgi.application"
WSGI_APPLICATION = 'things_api_project.wsgi.application'


# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases

DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}


# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/
# https://docs.djangoproject.com/en/5.0/topics/i18n/

LANGUAGE_CODE = "en-us"
LANGUAGE_CODE = 'en-us'

TIME_ZONE = "UTC"
TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
# https://docs.djangoproject.com/en/5.0/howto/static-files/

STATIC_URL = "static/"
STATIC_URL = 'static/'

# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

REST_FRAMEWORK = {
"DEFAULT_PERMISSION_CLASSES": [
"rest_framework.permissions.AllowAny",
]
}
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
7 changes: 4 additions & 3 deletions class-31/demo/things-api/things_api_project/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""things_api_project URL Configuration
"""
URL configuration for things_api_project project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.0/topics/http/urls/
https://docs.djangoproject.com/en/5.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
Expand All @@ -17,6 +18,6 @@
from django.urls import include, path

urlpatterns = [
path("admin/", admin.site.urls),
path('admin/', admin.site.urls),
path("api/v1/things/", include("things.urls")),
]
2 changes: 1 addition & 1 deletion class-31/demo/things-api/things_api_project/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/
"""

import os
Expand Down

0 comments on commit 604898a

Please sign in to comment.