├── LICENSE
├── README.md
├── db.sqlite3
├── inventory
├── __init__.py
├── __pycache__
│ ├── __init__.cpython-310.pyc
│ ├── admin.cpython-310.pyc
│ ├── apps.cpython-310.pyc
│ └── models.cpython-310.pyc
├── admin.py
├── apps.py
├── migrations
│ ├── 0001_initial.py
│ ├── 0002_producttwo_alter_brand_name.py
│ ├── __init__.py
│ └── __pycache__
│ │ ├── 0001_initial.cpython-310.pyc
│ │ ├── 0002_producttwo_alter_brand_name.cpython-310.pyc
│ │ └── __init__.cpython-310.pyc
├── models.py
├── tests.py
└── views.py
├── manage.py
├── project
├── __init__.py
├── __pycache__
│ ├── __init__.cpython-310.pyc
│ ├── settings.cpython-310.pyc
│ ├── urls.cpython-310.pyc
│ └── wsgi.cpython-310.pyc
├── asgi.py
├── settings.py
├── urls.py
└── wsgi.py
└── requirements.txt
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | Copyright (c) 2022, Jumayev Ubaydullo
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 |
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 |
8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Django ORM Base
4 |
5 |
--------------------------------------------------------------------------------
/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/python019/django-orm-base/86e004d759f7fccd358b415e1aa25e943e75b6bd/db.sqlite3
--------------------------------------------------------------------------------
/inventory/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/python019/django-orm-base/86e004d759f7fccd358b415e1aa25e943e75b6bd/inventory/__init__.py
--------------------------------------------------------------------------------
/inventory/__pycache__/__init__.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/python019/django-orm-base/86e004d759f7fccd358b415e1aa25e943e75b6bd/inventory/__pycache__/__init__.cpython-310.pyc
--------------------------------------------------------------------------------
/inventory/__pycache__/admin.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/python019/django-orm-base/86e004d759f7fccd358b415e1aa25e943e75b6bd/inventory/__pycache__/admin.cpython-310.pyc
--------------------------------------------------------------------------------
/inventory/__pycache__/apps.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/python019/django-orm-base/86e004d759f7fccd358b415e1aa25e943e75b6bd/inventory/__pycache__/apps.cpython-310.pyc
--------------------------------------------------------------------------------
/inventory/__pycache__/models.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/python019/django-orm-base/86e004d759f7fccd358b415e1aa25e943e75b6bd/inventory/__pycache__/models.cpython-310.pyc
--------------------------------------------------------------------------------
/inventory/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from .models import *
3 |
4 | admin.site.register((Brand, Category, Product, Stock, ProductTwo))
5 |
--------------------------------------------------------------------------------
/inventory/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class InventoryConfig(AppConfig):
5 | default_auto_field = "django.db.models.BigAutoField"
6 | name = "inventory"
7 |
--------------------------------------------------------------------------------
/inventory/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 4.1.3 on 2022-12-02 10:11
2 |
3 | from django.db import migrations, models
4 | import django.db.models.deletion
5 |
6 |
7 | class Migration(migrations.Migration):
8 |
9 | initial = True
10 |
11 | dependencies = []
12 |
13 | operations = [
14 | migrations.CreateModel(
15 | name="Brand",
16 | fields=[
17 | ("brand_id", models.BigAutoField(primary_key=True, serialize=False)),
18 | ("name", models.CharField(max_length=50)),
19 | ],
20 | ),
21 | migrations.CreateModel(
22 | name="Category",
23 | fields=[
24 | (
25 | "id",
26 | models.BigAutoField(
27 | auto_created=True,
28 | primary_key=True,
29 | serialize=False,
30 | verbose_name="ID",
31 | ),
32 | ),
33 | ("name", models.CharField(max_length=50)),
34 | ],
35 | options={
36 | "verbose_name_plural": "Categories",
37 | },
38 | ),
39 | migrations.CreateModel(
40 | name="Product",
41 | fields=[
42 | (
43 | "id",
44 | models.BigAutoField(
45 | auto_created=True,
46 | primary_key=True,
47 | serialize=False,
48 | verbose_name="ID",
49 | ),
50 | ),
51 | (
52 | "the_name",
53 | models.CharField(
54 | default="no-name",
55 | help_text="This is the help text",
56 | max_length=100,
57 | verbose_name="Product Name",
58 | ),
59 | ),
60 | ("age", models.IntegerField()),
61 | ("is_active", models.BooleanField(default=True)),
62 | ("category", models.ManyToManyField(to="inventory.category")),
63 | ],
64 | options={
65 | "ordering": ["age"],
66 | },
67 | ),
68 | migrations.CreateModel(
69 | name="Stock",
70 | fields=[
71 | (
72 | "id",
73 | models.BigAutoField(
74 | auto_created=True,
75 | primary_key=True,
76 | serialize=False,
77 | verbose_name="ID",
78 | ),
79 | ),
80 | ("units", models.BigIntegerField()),
81 | (
82 | "product",
83 | models.OneToOneField(
84 | on_delete=django.db.models.deletion.CASCADE,
85 | to="inventory.product",
86 | ),
87 | ),
88 | ],
89 | ),
90 | ]
91 |
--------------------------------------------------------------------------------
/inventory/migrations/0002_producttwo_alter_brand_name.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 4.1.3 on 2022-12-03 04:09
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ("inventory", "0001_initial"),
10 | ]
11 |
12 | operations = [
13 | migrations.CreateModel(
14 | name="ProductTwo",
15 | fields=[
16 | (
17 | "id",
18 | models.BigAutoField(
19 | auto_created=True,
20 | primary_key=True,
21 | serialize=False,
22 | verbose_name="ID",
23 | ),
24 | ),
25 | ("name", models.CharField(max_length=10)),
26 | ("price", models.DecimalField(decimal_places=2, max_digits=5)),
27 | ("data_added", models.DateTimeField(auto_now_add=True)),
28 | ("data_updated", models.DateTimeField(auto_now=True)),
29 | ("urls", models.SlugField()),
30 | ("is_active", models.BooleanField()),
31 | ],
32 | ),
33 | migrations.AlterField(
34 | model_name="brand",
35 | name="name",
36 | field=models.CharField(max_length=50, verbose_name="SUSYS"),
37 | ),
38 | ]
39 |
--------------------------------------------------------------------------------
/inventory/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/python019/django-orm-base/86e004d759f7fccd358b415e1aa25e943e75b6bd/inventory/migrations/__init__.py
--------------------------------------------------------------------------------
/inventory/migrations/__pycache__/0001_initial.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/python019/django-orm-base/86e004d759f7fccd358b415e1aa25e943e75b6bd/inventory/migrations/__pycache__/0001_initial.cpython-310.pyc
--------------------------------------------------------------------------------
/inventory/migrations/__pycache__/0002_producttwo_alter_brand_name.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/python019/django-orm-base/86e004d759f7fccd358b415e1aa25e943e75b6bd/inventory/migrations/__pycache__/0002_producttwo_alter_brand_name.cpython-310.pyc
--------------------------------------------------------------------------------
/inventory/migrations/__pycache__/__init__.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/python019/django-orm-base/86e004d759f7fccd358b415e1aa25e943e75b6bd/inventory/migrations/__pycache__/__init__.cpython-310.pyc
--------------------------------------------------------------------------------
/inventory/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | class Brand(models.Model):
4 | brand_id = models.BigAutoField(primary_key=True)
5 | name = models.CharField("SUSYS", max_length=50)
6 |
7 | def __str__(self) -> str:
8 | return self.name
9 |
10 | class Category(models.Model):
11 | name = models.CharField(max_length=50)
12 |
13 | class Meta:
14 | verbose_name_plural = "Categories"
15 |
16 | class Product(models.Model):
17 | the_name = models.CharField("Product Name", max_length=100, default="no-name", help_text="This is the help text")
18 | age = models.IntegerField()
19 | is_active = models.BooleanField(default=True)
20 | # category = models.ForeignKey(Category, on_delete=models.CASCADE)
21 | category = models.ManyToManyField(Category)
22 |
23 | class Meta:
24 | ordering = ["age"]
25 |
26 | def __str__(self):
27 | return f"Product name: {self.name}"
28 |
29 | class Stock(models.Model):
30 | units = models.BigIntegerField()
31 | product = models.OneToOneField(Product, on_delete=models.CASCADE)
32 |
33 | class ProductTwo(models.Model):
34 | name = models.CharField(max_length=10)
35 | price = models.DecimalField(max_digits=5, decimal_places=2)
36 | data_added = models.DateTimeField(auto_now_add=True)
37 | data_updated = models.DateTimeField(auto_now=True)
38 | urls = models.SlugField()
39 | is_active = models.BooleanField()
40 |
41 | def __str__(self) -> str:
42 | return self.name
--------------------------------------------------------------------------------
/inventory/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/inventory/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render
2 |
3 | # Create your views here.
4 |
--------------------------------------------------------------------------------
/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | """Run administrative tasks."""
9 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
10 | try:
11 | from django.core.management import execute_from_command_line
12 | except ImportError as exc:
13 | raise ImportError(
14 | "Couldn't import Django. Are you sure it's installed and "
15 | "available on your PYTHONPATH environment variable? Did you "
16 | "forget to activate a virtual environment?"
17 | ) from exc
18 | execute_from_command_line(sys.argv)
19 |
20 |
21 | if __name__ == "__main__":
22 | main()
23 |
--------------------------------------------------------------------------------
/project/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/python019/django-orm-base/86e004d759f7fccd358b415e1aa25e943e75b6bd/project/__init__.py
--------------------------------------------------------------------------------
/project/__pycache__/__init__.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/python019/django-orm-base/86e004d759f7fccd358b415e1aa25e943e75b6bd/project/__pycache__/__init__.cpython-310.pyc
--------------------------------------------------------------------------------
/project/__pycache__/settings.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/python019/django-orm-base/86e004d759f7fccd358b415e1aa25e943e75b6bd/project/__pycache__/settings.cpython-310.pyc
--------------------------------------------------------------------------------
/project/__pycache__/urls.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/python019/django-orm-base/86e004d759f7fccd358b415e1aa25e943e75b6bd/project/__pycache__/urls.cpython-310.pyc
--------------------------------------------------------------------------------
/project/__pycache__/wsgi.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/python019/django-orm-base/86e004d759f7fccd358b415e1aa25e943e75b6bd/project/__pycache__/wsgi.cpython-310.pyc
--------------------------------------------------------------------------------
/project/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for project project.
3 |
4 | It exposes the ASGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.asgi import get_asgi_application
13 |
14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/project/settings.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 |
3 | # Build paths inside the project like this: BASE_DIR / 'subdir'.
4 | BASE_DIR = Path(__file__).resolve().parent.parent
5 |
6 | # SECURITY WARNING: keep the secret key used in production secret!
7 | SECRET_KEY = "django-insecure-n3x3cl$l5=whrowrw^ufq_0k_=v=dv!i+&vwmg2!hpb^(vtcp8"
8 |
9 | # SECURITY WARNING: don't run with debug turned on in production!
10 | DEBUG = True
11 |
12 | ALLOWED_HOSTS = []
13 |
14 |
15 | # Application definition
16 |
17 | INSTALLED_APPS = [
18 | "django.contrib.admin",
19 | "django.contrib.auth",
20 | "django.contrib.contenttypes",
21 | "django.contrib.sessions",
22 | "django.contrib.messages",
23 | "django.contrib.staticfiles",
24 | "inventory"
25 | ]
26 |
27 | MIDDLEWARE = [
28 | "django.middleware.security.SecurityMiddleware",
29 | "django.contrib.sessions.middleware.SessionMiddleware",
30 | "django.middleware.common.CommonMiddleware",
31 | "django.middleware.csrf.CsrfViewMiddleware",
32 | "django.contrib.auth.middleware.AuthenticationMiddleware",
33 | "django.contrib.messages.middleware.MessageMiddleware",
34 | "django.middleware.clickjacking.XFrameOptionsMiddleware",
35 | ]
36 |
37 | ROOT_URLCONF = "project.urls"
38 |
39 | TEMPLATES = [
40 | {
41 | "BACKEND": "django.template.backends.django.DjangoTemplates",
42 | "DIRS": [],
43 | "APP_DIRS": True,
44 | "OPTIONS": {
45 | "context_processors": [
46 | "django.template.context_processors.debug",
47 | "django.template.context_processors.request",
48 | "django.contrib.auth.context_processors.auth",
49 | "django.contrib.messages.context_processors.messages",
50 | ],
51 | },
52 | },
53 | ]
54 |
55 | WSGI_APPLICATION = "project.wsgi.application"
56 |
57 |
58 | # Database
59 | # https://docs.djangoproject.com/en/4.1/ref/settings/#databases
60 |
61 | DATABASES = {
62 | "default": {
63 | "ENGINE": "django.db.backends.sqlite3",
64 | "NAME": BASE_DIR / "db.sqlite3",
65 | }
66 | }
67 |
68 |
69 | # Password validation
70 | # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
71 |
72 | AUTH_PASSWORD_VALIDATORS = [
73 | {
74 | "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
75 | },
76 | {
77 | "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
78 | },
79 | {
80 | "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
81 | },
82 | {
83 | "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
84 | },
85 | ]
86 |
87 |
88 | # Internationalization
89 | # https://docs.djangoproject.com/en/4.1/topics/i18n/
90 |
91 | LANGUAGE_CODE = "en-us"
92 |
93 | TIME_ZONE = "UTC"
94 |
95 | USE_I18N = True
96 |
97 | USE_TZ = True
98 |
99 |
100 | # Static files (CSS, JavaScript, Images)
101 | # https://docs.djangoproject.com/en/4.1/howto/static-files/
102 |
103 | STATIC_URL = "static/"
104 |
105 | # Default primary key field type
106 | # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
107 |
108 | DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
109 |
--------------------------------------------------------------------------------
/project/urls.py:
--------------------------------------------------------------------------------
1 | """project URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/4.1/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import path
18 |
19 | urlpatterns = [
20 | path("admin/", admin.site.urls),
21 | ]
22 |
--------------------------------------------------------------------------------
/project/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for project project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | asgiref==3.5.2
2 | Django==4.1.3
3 | sqlparse==0.4.3
4 |
--------------------------------------------------------------------------------