diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4c49bd78f1d08f2bc09fa0bd8191ed38b7dce5e3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/book_management_system/book_management_system/__init__.py b/book_management_system/book_management_system/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/book_management_system/book_management_system/__pycache__/__init__.cpython-37.pyc b/book_management_system/book_management_system/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b84ef043ab77460d1384e72866b0c8a0e2b706ae Binary files /dev/null and b/book_management_system/book_management_system/__pycache__/__init__.cpython-37.pyc differ diff --git a/book_management_system/book_management_system/__pycache__/settings.cpython-37.pyc b/book_management_system/book_management_system/__pycache__/settings.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2e8a4141247920cb284741983e15628baca103f2 Binary files /dev/null and b/book_management_system/book_management_system/__pycache__/settings.cpython-37.pyc differ diff --git a/book_management_system/book_management_system/__pycache__/urls.cpython-37.pyc b/book_management_system/book_management_system/__pycache__/urls.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..02c7864d1d1f80052671476ee39e826f87ebf074 Binary files /dev/null and b/book_management_system/book_management_system/__pycache__/urls.cpython-37.pyc differ diff --git a/book_management_system/book_management_system/__pycache__/wsgi.cpython-37.pyc b/book_management_system/book_management_system/__pycache__/wsgi.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..af3d47b023d63de6b190d685d6e2ff9e5e6c66b7 Binary files /dev/null and b/book_management_system/book_management_system/__pycache__/wsgi.cpython-37.pyc differ diff --git a/book_management_system/book_management_system/asgi.py b/book_management_system/book_management_system/asgi.py new file mode 100644 index 0000000000000000000000000000000000000000..1ffbed7a32332e247bf12cd46ac5d2cd0556f6f3 --- /dev/null +++ b/book_management_system/book_management_system/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for book_management_system project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'book_management_system.settings') + +application = get_asgi_application() diff --git a/book_management_system/book_management_system/settings.py b/book_management_system/book_management_system/settings.py new file mode 100644 index 0000000000000000000000000000000000000000..258de4dd62ce225669f2902f705e96cd49152d3d --- /dev/null +++ b/book_management_system/book_management_system/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for book_management_system project. + +Generated by 'django-admin startproject' using Django 3.1.4. + +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 + +# 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 = 'w_f#_u9s8p^u8)xtdi13k7oo+6m6oak11vm0cz45)xuqh4)024' + +# 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', + # local apps + 'online_books', +] + +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 = 'book_management_system.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 = 'book_management_system.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': 'books_db', + 'USER': 'postgres', + 'PASSWORD': 'hiru007coding', + 'HOST': 'localhost', + 'PORT': '5432', + } +} + + +# 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/' diff --git a/book_management_system/book_management_system/urls.py b/book_management_system/book_management_system/urls.py new file mode 100644 index 0000000000000000000000000000000000000000..102283bdc11cdf9603385cb31c24bd9d09ef97b8 --- /dev/null +++ b/book_management_system/book_management_system/urls.py @@ -0,0 +1,21 @@ +"""book_management_system URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/3.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] \ No newline at end of file diff --git a/book_management_system/book_management_system/wsgi.py b/book_management_system/book_management_system/wsgi.py new file mode 100644 index 0000000000000000000000000000000000000000..bff50f8bd04c77cef98213604a0e5af62c9c4df1 --- /dev/null +++ b/book_management_system/book_management_system/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for book_management_system project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'book_management_system.settings') + +application = get_wsgi_application() diff --git a/book_management_system/manage.py b/book_management_system/manage.py new file mode 100644 index 0000000000000000000000000000000000000000..606d67c99705985fffb91f69cee7be9402eb00cf --- /dev/null +++ b/book_management_system/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'book_management_system.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) + + +if __name__ == '__main__': + main() diff --git a/book_management_system/online_books/__init__.py b/book_management_system/online_books/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/book_management_system/online_books/__pycache__/__init__.cpython-37.pyc b/book_management_system/online_books/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..130bb973ca20a563769acb45d761e65b9f3671ba Binary files /dev/null and b/book_management_system/online_books/__pycache__/__init__.cpython-37.pyc differ diff --git a/book_management_system/online_books/__pycache__/admin.cpython-37.pyc b/book_management_system/online_books/__pycache__/admin.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5f8c31bca6cf7a92597717e4e610e3befd389c37 Binary files /dev/null and b/book_management_system/online_books/__pycache__/admin.cpython-37.pyc differ diff --git a/book_management_system/online_books/__pycache__/models.cpython-37.pyc b/book_management_system/online_books/__pycache__/models.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ab0d4ee85513f44906b29cb39f1808af5eda1fea Binary files /dev/null and b/book_management_system/online_books/__pycache__/models.cpython-37.pyc differ diff --git a/book_management_system/online_books/admin.py b/book_management_system/online_books/admin.py new file mode 100644 index 0000000000000000000000000000000000000000..2a91d8d1f1f06ec0d34ab9446e9500ef1c86fd02 --- /dev/null +++ b/book_management_system/online_books/admin.py @@ -0,0 +1,10 @@ +from django.contrib import admin +from .models import * + +admin.site.site_header = 'Book Management System' +admin.site.site_title = 'Online Books' +admin.site.index_title = 'Admin' + +admin.site.register(Genre) +admin.site.register(Author) +admin.site.register(Book) \ No newline at end of file diff --git a/book_management_system/online_books/apps.py b/book_management_system/online_books/apps.py new file mode 100644 index 0000000000000000000000000000000000000000..ec9c1c903955321e7c3844992a72b3544f9a0088 --- /dev/null +++ b/book_management_system/online_books/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class OnlineBooksConfig(AppConfig): + name = 'online_books' diff --git a/book_management_system/online_books/migrations/0001_initial.py b/book_management_system/online_books/migrations/0001_initial.py new file mode 100644 index 0000000000000000000000000000000000000000..6809e52e8cb73eef52133df8aacf90d082056e67 --- /dev/null +++ b/book_management_system/online_books/migrations/0001_initial.py @@ -0,0 +1,40 @@ +# Generated by Django 3.1.4 on 2020-12-26 10:52 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Author', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('author_name', models.CharField(max_length=100, unique=True)), + ], + ), + migrations.CreateModel( + name='Genre', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('genre_name', models.CharField(max_length=100, unique=True)), + ], + ), + migrations.CreateModel( + name='Book', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('book_title', models.CharField(max_length=100)), + ('description', models.TextField(max_length=400)), + ('price', models.FloatField(help_text='In rupees (₹)')), + ('author_fk', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='online_books.author')), + ('genres', models.ManyToManyField(to='online_books.Genre')), + ], + ), + ] diff --git a/book_management_system/online_books/migrations/__init__.py b/book_management_system/online_books/migrations/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/book_management_system/online_books/migrations/__pycache__/0001_initial.cpython-37.pyc b/book_management_system/online_books/migrations/__pycache__/0001_initial.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5476104df5980376802ee22084cec39c1f56bcc3 Binary files /dev/null and b/book_management_system/online_books/migrations/__pycache__/0001_initial.cpython-37.pyc differ diff --git a/book_management_system/online_books/migrations/__pycache__/__init__.cpython-37.pyc b/book_management_system/online_books/migrations/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..35632000ecb03a87be41d6d6c4aa4b8dd95480aa Binary files /dev/null and b/book_management_system/online_books/migrations/__pycache__/__init__.cpython-37.pyc differ diff --git a/book_management_system/online_books/models.py b/book_management_system/online_books/models.py new file mode 100644 index 0000000000000000000000000000000000000000..b47982d35a29373a3825c789a063c1eacabd6ad4 --- /dev/null +++ b/book_management_system/online_books/models.py @@ -0,0 +1,23 @@ +from django.db import models + +class Genre(models.Model): + genre_name = models.CharField(max_length=100, unique=True) + + def __str__(self): + return self.genre_name + +class Author(models.Model): + author_name = models.CharField(max_length=100, unique=True) + + def __str__(self): + return self.author_name + +class Book(models.Model): + book_title = models.CharField(max_length=100) + author_fk = models.ForeignKey('Author', on_delete=models.CASCADE) + genres = models.ManyToManyField('Genre') + description = models.TextField(max_length=400, null=True, blank=True) + price = models.FloatField(help_text="In rupees (₹)") + + def __str__(self): + return self.book_title diff --git a/book_management_system/online_books/tests.py b/book_management_system/online_books/tests.py new file mode 100644 index 0000000000000000000000000000000000000000..7ce503c2dd97ba78597f6ff6e4393132753573f6 --- /dev/null +++ b/book_management_system/online_books/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/book_management_system/online_books/views.py b/book_management_system/online_books/views.py new file mode 100644 index 0000000000000000000000000000000000000000..91ea44a218fbd2f408430959283f0419c921093e --- /dev/null +++ b/book_management_system/online_books/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..4bb9f474c2a7b00cc406a1ad48d753210b6ff426 Binary files /dev/null and b/requirements.txt differ