From 41796e1453a01ff870ff6eb5414e4bbac5e2f52a Mon Sep 17 00:00:00 2001 From: MrNihalT Date: Sat, 30 May 2026 14:43:10 +0530 Subject: [PATCH] Add initial django backend setup --- .github/CONTRIBUTING.md | 0 .gitignore | 5 + backend/.gitignore | 8 ++ backend/bookings/__init__.py | 0 backend/bookings/admin.py | 4 + backend/bookings/apps.py | 5 + backend/bookings/migrations/0001_initial.py | 28 +++++ backend/bookings/migrations/__init__.py | 0 backend/bookings/models.py | 13 +++ backend/bookings/tests.py | 3 + backend/bookings/views.py | 3 + backend/bookmyvenue/__init__.py | 0 backend/bookmyvenue/asgi.py | 16 +++ backend/bookmyvenue/settings.py | 116 ++++++++++++++++++++ backend/bookmyvenue/urls.py | 12 ++ backend/bookmyvenue/wsgi.py | 16 +++ backend/manage.py | 22 ++++ backend/requirements.txt | Bin 0 -> 272 bytes backend/venues/__init__.py | 0 backend/venues/admin.py | 5 + backend/venues/apps.py | 5 + backend/venues/migrations/0001_initial.py | 29 +++++ backend/venues/migrations/__init__.py | 0 backend/venues/models.py | 16 +++ backend/venues/tests.py | 3 + backend/venues/views.py | 3 + 26 files changed, 312 insertions(+) create mode 100644 .github/CONTRIBUTING.md create mode 100644 .gitignore create mode 100644 backend/.gitignore create mode 100644 backend/bookings/__init__.py create mode 100644 backend/bookings/admin.py create mode 100644 backend/bookings/apps.py create mode 100644 backend/bookings/migrations/0001_initial.py create mode 100644 backend/bookings/migrations/__init__.py create mode 100644 backend/bookings/models.py create mode 100644 backend/bookings/tests.py create mode 100644 backend/bookings/views.py create mode 100644 backend/bookmyvenue/__init__.py create mode 100644 backend/bookmyvenue/asgi.py create mode 100644 backend/bookmyvenue/settings.py create mode 100644 backend/bookmyvenue/urls.py create mode 100644 backend/bookmyvenue/wsgi.py create mode 100644 backend/manage.py create mode 100644 backend/requirements.txt create mode 100644 backend/venues/__init__.py create mode 100644 backend/venues/admin.py create mode 100644 backend/venues/apps.py create mode 100644 backend/venues/migrations/0001_initial.py create mode 100644 backend/venues/migrations/__init__.py create mode 100644 backend/venues/models.py create mode 100644 backend/venues/tests.py create mode 100644 backend/venues/views.py diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 00000000..e69de29b diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..6dc24a35 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +backend/venv/ + +**/__pycache__/ +*.pyc +.env \ No newline at end of file diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 00000000..674aeef6 --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1,8 @@ +venv/ +env/ +.venv/ + +__pycache__/ +*.pyc + + diff --git a/backend/bookings/__init__.py b/backend/bookings/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/backend/bookings/admin.py b/backend/bookings/admin.py new file mode 100644 index 00000000..f1e5e419 --- /dev/null +++ b/backend/bookings/admin.py @@ -0,0 +1,4 @@ +from django.contrib import admin +from bookings.models import Booking + +admin.site.register(Booking) diff --git a/backend/bookings/apps.py b/backend/bookings/apps.py new file mode 100644 index 00000000..63907ab3 --- /dev/null +++ b/backend/bookings/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class BookingsConfig(AppConfig): + name = 'bookings' diff --git a/backend/bookings/migrations/0001_initial.py b/backend/bookings/migrations/0001_initial.py new file mode 100644 index 00000000..ff7e7110 --- /dev/null +++ b/backend/bookings/migrations/0001_initial.py @@ -0,0 +1,28 @@ +# Generated by Django 6.0.5 on 2026-05-30 09:05 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('venues', '0001_initial'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Booking', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('booking_date', models.DateField()), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ('venue', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='venues.venue')), + ], + ), + ] diff --git a/backend/bookings/migrations/__init__.py b/backend/bookings/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/backend/bookings/models.py b/backend/bookings/models.py new file mode 100644 index 00000000..7ae905c0 --- /dev/null +++ b/backend/bookings/models.py @@ -0,0 +1,13 @@ +from django.db import models +from django.contrib.auth.models import User +from venues.models import Venue + + +class Booking(models.Model): + user = models.ForeignKey(User, on_delete=models.CASCADE) + venue = models.ForeignKey(Venue, on_delete=models.CASCADE) + booking_date = models.DateField() + created_at = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return f"{self.user.username} - {self.venue.name}" \ No newline at end of file diff --git a/backend/bookings/tests.py b/backend/bookings/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/backend/bookings/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/backend/bookings/views.py b/backend/bookings/views.py new file mode 100644 index 00000000..91ea44a2 --- /dev/null +++ b/backend/bookings/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/backend/bookmyvenue/__init__.py b/backend/bookmyvenue/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/backend/bookmyvenue/asgi.py b/backend/bookmyvenue/asgi.py new file mode 100644 index 00000000..4e122052 --- /dev/null +++ b/backend/bookmyvenue/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for bookmyvenue 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/6.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bookmyvenue.settings') + +application = get_asgi_application() diff --git a/backend/bookmyvenue/settings.py b/backend/bookmyvenue/settings.py new file mode 100644 index 00000000..3d14458d --- /dev/null +++ b/backend/bookmyvenue/settings.py @@ -0,0 +1,116 @@ + + +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/6.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-pp#bcu6kn88bq@v95klpb2mx9recrayeue=iao+)c-gy1qv%cf' + +# 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', + 'venues', + 'bookings', +] + +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 = 'bookmyvenue.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'bookmyvenue.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/6.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'bookmyvenue', + 'USER': 'postgres', + 'PASSWORD': '9292', + 'HOST': 'localhost', + + } +} + + +# Password validation +# https://docs.djangoproject.com/en/6.0/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/6.0/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/6.0/howto/static-files/ + +STATIC_URL = 'static/' + +MEDIA_URL = "/media/" +MEDIA_ROOT = BASE_DIR / "media" diff --git a/backend/bookmyvenue/urls.py b/backend/bookmyvenue/urls.py new file mode 100644 index 00000000..1eff36de --- /dev/null +++ b/backend/bookmyvenue/urls.py @@ -0,0 +1,12 @@ +from django.conf import settings +from django.conf.urls.static import static +from django.contrib import admin +from django.urls import path + + +urlpatterns = [ + path('admin/', admin.site.urls), +] + +if settings.DEBUG: + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file diff --git a/backend/bookmyvenue/wsgi.py b/backend/bookmyvenue/wsgi.py new file mode 100644 index 00000000..10580939 --- /dev/null +++ b/backend/bookmyvenue/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for bookmyvenue 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/6.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bookmyvenue.settings') + +application = get_wsgi_application() diff --git a/backend/manage.py b/backend/manage.py new file mode 100644 index 00000000..012c9f67 --- /dev/null +++ b/backend/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', 'bookmyvenue.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/backend/requirements.txt b/backend/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..fb5c9870492d5eadd2bb6c2210bfcee9f34129c8 GIT binary patch literal 272 zcmYk1+X})k5Jcx$@KcmFqT+*Z{z$bd-rAT1L_c0Vo1m0s1If&s-F)7SqK-N#Xs?6T z)J#*=l$~RZw9#3OI$V9$7bq1y&uTkRjS-dL1QIuH4>CcQ0eAW5dZu2f9+%Cn<