From b9b6d28dda6e5791c115f5dd1765272484243a5d Mon Sep 17 00:00:00 2001 From: Leo Prissberg <146682762+DatBoiWhoWon@users.noreply.github.com> Date: Tue, 21 Oct 2025 07:31:18 +0000 Subject: [PATCH] adding Products app --- firstdjango/firstdjango/Products/__init__.py | 0 firstdjango/firstdjango/Products/apps.py | 6 + .../Products/migrations/__init__.py | 0 firstdjango/firstdjango/Products/models.py | 8 ++ firstdjango/firstdjango/Products/tests.py | 3 + firstdjango/firstdjango/Products/views.py | 3 + firstdjango/firstdjango/settings.py | 124 ++++++++++++++++++ 7 files changed, 144 insertions(+) create mode 100644 firstdjango/firstdjango/Products/__init__.py create mode 100644 firstdjango/firstdjango/Products/apps.py create mode 100644 firstdjango/firstdjango/Products/migrations/__init__.py create mode 100644 firstdjango/firstdjango/Products/models.py create mode 100644 firstdjango/firstdjango/Products/tests.py create mode 100644 firstdjango/firstdjango/Products/views.py create mode 100644 firstdjango/firstdjango/settings.py diff --git a/firstdjango/firstdjango/Products/__init__.py b/firstdjango/firstdjango/Products/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/firstdjango/firstdjango/Products/apps.py b/firstdjango/firstdjango/Products/apps.py new file mode 100644 index 00000000000..64a944ed915 --- /dev/null +++ b/firstdjango/firstdjango/Products/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ProductsConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'Products' diff --git a/firstdjango/firstdjango/Products/migrations/__init__.py b/firstdjango/firstdjango/Products/migrations/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/firstdjango/firstdjango/Products/models.py b/firstdjango/firstdjango/Products/models.py new file mode 100644 index 00000000000..a046305b1b4 --- /dev/null +++ b/firstdjango/firstdjango/Products/models.py @@ -0,0 +1,8 @@ +from django.db import models + +# Create your models here. +class Products(models.Model): + title = models.TextField() + description = models.TextField() + price = models.TextField() + summary = models.TextField() \ No newline at end of file diff --git a/firstdjango/firstdjango/Products/tests.py b/firstdjango/firstdjango/Products/tests.py new file mode 100644 index 00000000000..de8bdc00eb2 --- /dev/null +++ b/firstdjango/firstdjango/Products/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/firstdjango/firstdjango/Products/views.py b/firstdjango/firstdjango/Products/views.py new file mode 100644 index 00000000000..c60c7904370 --- /dev/null +++ b/firstdjango/firstdjango/Products/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/firstdjango/firstdjango/settings.py b/firstdjango/firstdjango/settings.py new file mode 100644 index 00000000000..c05d9235b56 --- /dev/null +++ b/firstdjango/firstdjango/settings.py @@ -0,0 +1,124 @@ +""" +Django settings for firstdjango project. + +Generated by 'django-admin startproject' using Django 4.2.25. + +For more information on this file, see +https://docs.djangoproject.com/en/4.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.2/ref/settings/ +""" + +from pathlib import Path + +# 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.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-ld($((0czb9^s_axz2+e*gf%)-3a8zfd&x!#lk%_luo6o=m^2_' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'Products' +] + +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 = 'firstdjango.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', + ], + }, + }, +] + +WSGI_APPLICATION = 'firstdjango.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/4.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.2/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.2/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.2/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'