Home

  1. Develop a Django app that displays current date and time in server
  2. Develop a Django app that displays date and time four hours ahead and four hours before as an offset of current date and time in server.
  3. Develop a simple Django app that displays an unordered list of fruits and ordered list of selected students for an event
  4. Develop a layout.html with a suitable header (containing navigation menu) and footer with copyright and developer information. Inherit this layout.html and create 3 additional pages: contact us, About Us and Home page of any website.
  5. Develop a Django app that performs student registration to a course. It should also display list of students registered for any selected course. Create students and course as models with enrolment as ManyToMany field.
  6. For student and course models created in Lab experiment for Module2, register admin interfaces, perform migrations and illustrate data entry through admin forms.
  7. Develop a Model form for student that contains his topic chosen for project, languages used and duration with a model called project.
  8. For students enrolment developed in Module 2, create a generic class view which displays list of students and detailview that displays student details for any selected student in the list.
  9. Develop example Django app that performs CSV and PDF generation for any models created in previous laboratory component.
  10. Develop a registration page for student enrolment as done in Module 2 but without page refresh using AJAX.
  11. Develop a search application in Django using AJAX that displays courses enrolled by a student being searched.

Program 1

Develop a Django app that displays current date and time in server

views.py

from django.shortcuts import render
from django.http import HttpResponse
import datetime

# Create your views here.
def cdt(req):
    res = f"The time is {datetime.datetime.now()}"
    return HttpResponse(res)

urls.py

from django.urls import path
from . import views

urlpatterns = [
    path('dt', views.cdt, name='p1'),
]

Program 2

Develop a Django app that displays date and time four hours ahead and four hours before as an offset of current date and time in server.

views.py

from django.shortcuts import render
from django.http import HttpResponse
import datetime

# Create your views here.
def cdtn(req, n):
    res = f"The time after {n} hours will be {datetime.datetime.now() + datetime.timedelta(hours=n)}"
    res += f"<br />The time {n} hours ago was {datetime.datetime.now() - datetime.timedelta(hours=n)}"
    return HttpResponse(res)

urls.py

from django.urls import path
from . import views

urlpatterns = [
    path('dt/<int:n>', views.cdtn, name='p2'),
]

Program 3

Develop a simple Django app that displays an unordered list of fruits and ordered list of selected students for an event

views.py

from django.shortcuts import render

# Create your views here.
def prog3func(request):
    context = {
        'fruits' : ['Apple','Banana','Cherry'],
        'students' : ['Ram','Sam','Tam','Zam']
    }

    return render(request,'listy.html',context)

urls.py

from django.urls import path
from . import views

urlpatterns = [
    path('listy', views.prog3func, name='p3'),
]

templates/listy.html

<!DOCTYPE html>
<html>
    <head>
        <title>Program 3</title>
        <style>
            body {
                background-color: orange;
                font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
            }

            ul {
                color: blue;
                list-style-type: square;
            }
            ol {
                color: green;
                list-style-type: upper-roman;
            }
        </style>
    </head>
    <body>
        <h1>Unordered Fruits List</h1>
        <ul>
            {{fruits | unordered_list}}
        </ul>
        <br><br>
        <h1>Ordered Students List</h1>
        <ol>
            {% for student in students %}
                <li>Student #{{forloop.counter}} is {{student}}</li>
            {% endfor %}
        </ol>
    </body>
</html>

Program 4

Develop a layout.html with a suitable header (containing navigation menu) and footer with copyright and developer information. Inherit this layout.html and create 3 additional pages: contact us, About Us and Home page of any website.

views.py

from django.shortcuts import render

# Create your views here.
def home(request):
    return render(request, 'home.html')

def about(request):
    return render(request, 'about.html')

def contact(request):
    return render(request, 'contact.html')

urls.py

from django.urls import path
from . import views

urlpatterns = [
    path('home', views.home),
    path('about', views.about),
    path('contact', views.contact),
]

templates/layout.html

<!DOCTYPE html>
<head>
  <title>{% block title %} Program 4 default title {% endblock %}</title>
  <style>
    body {
      background-color: rgb(202, 186, 216);
    }
    nav {
      display: flex;
      justify-content: space-between;
      align-items: center;
      background-color: aquamarine;
      padding: 10px 20px;
      border-radius: 5px;
      text-decoration: none;
    }

    footer {
        display: flex;
        justify-content: center;
        background-color: rgb(238, 238, 238);
        padding: 10px 20px;
        border-radius: 5px;
    }

    a {
      text-decoration: none;
      color: rgb(50, 50, 50);
    }

    a:hover {
      text-decoration: underline;
    }

    #links {
      display: flex;
      gap: 10px;
      background-color: rgb(198, 151, 117);
      padding: 10px;
      border-radius: 6px;
    }
  </style>
</head>
<body>
  <nav>
    <div>
      <a href="home">DEV SITE</a>
    </div>
    <div id="links">
      <a href="home">Home</a> 
      <a href="about">About</a> 
      <a href="contact">Contact Us</a> 
    </div>
  </nav>

  {% block content %}{% endblock %}

  <footer>
    <center>&copy ayshmnmm 2024</center>
  </footer>
</body>

templates/contact.html

{% extends "layout.html" %}

{% block title %}Contact{% endblock %}

{% block content %}
    <h1>Contact Us</h1>
    <p>Send us a message!</p>
    <a href="tel:123-456-7890">Call us</a>
{% endblock %}

templates/about.html

{% extends "layout.html" %} 
{% block title %}About{% endblock %} 
{% block content %}
<h1>About Us</h1>
<p>
  We are the best dev company in the world!
</p>
{% endblock %}

templates/home.html

{% extends "layout.html" %}

{% block title %}Home{% endblock %}

{% block content %}
    <h1>Home</h1>
    <p>Welcome to the home page!</p>
{% endblock %}

Program 5

Develop a Django app that performs student registration to a course. It should also display list of students registered for any selected course. Create students and course as models with enrolment as ManyToMany field.

views.py

from django.shortcuts import render
from django.http import HttpResponse

# Create your views here.
from .models import Student,Course
def insertstudent(request):
    s1=Student(usn='21CS001', name='ABITH', sem=6)
    s2=Student(usn='21CS002', name='RAM', sem=6)
    s3=Student(usn='21CS003', name='SAM', sem=6)
    s4=Student(usn='21CS004', name='KUMAR', sem=6)
    s5=Student(usn='21CS005', name='RAJ', sem=6)
    for x in [s1,s2,s3,s4,s5]:
        x.save()
    return HttpResponse("insertion of student data successful")

def insertcourse(request):
    c1=Course(cid='21CS61',cname='SEPM')
    c2=Course(cid='21CS62',cname='FD')
    c3=Course(cid='21CS63',cname='CG')
    c4=Course(cid='21CS641',cname='AJJ')
    c5=Course(cid='21CS642',cname='DSV')
    for x in [c1,c2,c3,c4,c5]:
        x.save()
    return HttpResponse("insertion of course data successful") 

def enrollment(request,s,c):
    s=Student.objects.get(usn=s)
    l=c.split(',')
    for x in l:
        cc=Course.objects.get(cname=x)
        s.courses.add(cc)
    return HttpResponse("course enrollment successful") 

def display(request):
    s=Student.objects.all()
    res="<table border='2'><tr><th>USN</th><th>   NAME </th> <th> SEM </th><th>   COURSES</th></tr>"
    for x in s:
        res+="<tr><td>"+x.usn+"</td><td>"+x.name+"</td><td> "+str(x.sem)+"</td><td>  "
        l=x.courses.all().values()
        for a in l:
            res+=a['cname']+" , "
        res+="</td></tr>"
    res+="</table>"
    return HttpResponse(res)

urls.py

from django.urls import path
from . import views

urlpatterns = [
    path('student',views.insertstudent),
    path('course',views.insertcourse),
    path('enroll/<str:s>/<str:c>',views.enrollment),
    path('display',views.display),
]

models.py

from django.db import models

# Create your models here.
class Course(models.Model):
    cid=models.CharField(max_length=10, primary_key=True)
    cname=models.CharField(max_length=30)

class Student(models.Model):
    usn=models.CharField(max_length=10, primary_key=True)
    name=models.CharField(max_length=30)
    sem=models.IntegerField()
    courses=models.ManyToManyField(Course)

Program 6

For student and course models created in Lab experiment for Module2, register admin interfaces, perform migrations and illustrate data entry through admin forms.

views.py

from django.shortcuts import render
from django.http import HttpResponse

# Create your views here.
from .models import Student,Course
def insertstudent(request):
    s1=Student(usn='21CS001', name='ABITH', sem=6)
    s2=Student(usn='21CS002', name='RAM', sem=6)
    s3=Student(usn='21CS003', name='SAM', sem=6)
    s4=Student(usn='21CS004', name='KUMAR', sem=6)
    s5=Student(usn='21CS005', name='RAJ', sem=6)
    for x in [s1,s2,s3,s4,s5]:
        x.save()
    return HttpResponse("insertion of student data successful")

def insertcourse(request):
    c1=Course(cid='21CS61',cname='SEPM')
    c2=Course(cid='21CS62',cname='FD')
    c3=Course(cid='21CS63',cname='CG')
    c4=Course(cid='21CS641',cname='AJJ')
    c5=Course(cid='21CS642',cname='DSV')
    for x in [c1,c2,c3,c4,c5]:
        x.save()
    return HttpResponse("insertion of course data successful") 

def enrollment(request,s,c):
    s=Student.objects.get(usn=s)
    l=c.split(',')
    for x in l:
        cc=Course.objects.get(cname=x)
        s.courses.add(cc)
    return HttpResponse("course enrollment successful") 

def display(request):
    s=Student.objects.all()
    res="<table border='2'><tr><th>USN</th><th>   NAME </th> <th> SEM </th><th>   COURSES</th></tr>"
    for x in s:
        res+="<tr><td>"+x.usn+"</td><td>"+x.name+"</td><td> "+str(x.sem)+"</td><td>  "
        l=x.courses.all().values()
        for a in l:
            res+=a['cname']+" , "
        res+="</td></tr>"
    res+="</table>"
    return HttpResponse(res)

urls.py

from django.urls import path
from . import views

urlpatterns = [
    path('student',views.insertstudent),
    path('course',views.insertcourse),
    path('enroll/<str:s>/<str:c>',views.enrollment),
    path('display',views.display),
]

models.py

from django.db import models

# Create your models here.
class Course(models.Model):
    cid=models.CharField(max_length=10, primary_key=True)
    cname=models.CharField(max_length=30)

class Student(models.Model):
    usn=models.CharField(max_length=10, primary_key=True)
    name=models.CharField(max_length=30)
    sem=models.IntegerField()
    courses=models.ManyToManyField(Course)

admin.py

from django.contrib import admin

# Register your models here.
from .models import Course,Student

class StudentAdmin(admin.ModelAdmin):
    list_display = ('usn', 'name', 'sem')
    list_filter = ['sem']
    search_fields = ['name', 'usn']
    ordering = ['name']

class CourseAdmin(admin.ModelAdmin):
    list_display = ('cid', 'cname')
    search_fields = ['cname', 'cid']
    ordering = ['cname']

admin.site.register(Student, StudentAdmin)
admin.site.register(Course, CourseAdmin)

Program 7

Develop a Model form for student that contains his topic chosen for project, languages used and duration with a model called project.

views.py

from django.shortcuts import render
from .forms import ProjectForm
from django.http import HttpResponse

# Create your views here.

def insertproject(request):
    if request.method == 'POST':
        form = ProjectForm(request.POST)
        if form.is_valid():
            form.save()
        return HttpResponse("Record inserted successfully")
    form = ProjectForm()
    return render(request, 'insertproject.html', {'form': form})
    

urls.py

from django.urls import path
from . import views

urlpatterns = [
    path('projectreg', views.insertproject)
]

models.py

from django.db import models

# Create your models here.
# Develop a Model form for student that contains his topic chosen for project, languages used and
# duration with a model called project.
class Student(models.Model):
    usn=models.CharField(max_length=10, primary_key=True)
    name=models.CharField(max_length=30)
    sem=models.IntegerField()

class Project(models.Model):
    topic=models.CharField(max_length=30)
    languages=models.CharField(max_length=30)
    duration=models.IntegerField()
    student=models.ForeignKey(Student,on_delete=models.CASCADE)

forms.py

# Develop a Model form for student that contains his topic chosen for project, languages used and
# duration with a model called project.

from django import forms
from .models import  Project


class ProjectForm(forms.ModelForm):
    class Meta:
        model = Project
        fields = '__all__'

admin.py

from django.contrib import admin
from .models import Project, Student

# Register your models here.
class P(admin.ModelAdmin):
    list_display = ('student','duration','languages','topic')

admin.site.register(Project, P)
admin.site.register(Student)

templates/insertproject.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>project insert</title>
  </head>
  <body>
    <form method="POST" action="">
      {% csrf_token %}
      <table>
        {{ form.as_table }}
        <tr>
          <td><input type="submit" value="Insert" /></td>
        </tr>
      </table>
    </form>
  </body>
</html>

Program 8

For students enrolment developed in Module 2, create a generic class view which displays list of students and detailview that displays student details for any selected student in the list.

views.py

from django.shortcuts import render
from django.views import generic
from .models import Student

# Create your views here.
class StudentListView(generic.ListView):
    model=Student
    template_name="student_list.html"
    
class StudentDetailView(generic.DetailView):
    model=Student
    template_name="student_detail.html"

urls.py

from django.urls import path
from .views import StudentDetailView,StudentListView

urlpatterns = [
    path('student_list/', StudentListView.as_view()),
    path('student_detail/<int:pk>/', StudentDetailView.as_view()),
]

models.py

from django.db import models

# Create your models here.
class Course(models.Model):
    course_code=models.CharField(max_length=40)
    course_name=models.CharField(max_length=100)
    course_credits=models.IntegerField()

class Student(models.Model):
    student_usn=models.CharField(max_length=20,)
    student_name=models.CharField(max_length=100)
    student_sem=models.IntegerField()
    enrolment=models.ManyToManyField(Course)
    

admin.py

from django.contrib import admin
from django.contrib import admin
from .models import Student,Course

admin.site.register(Student)
admin.site.register(Course)

templates/student_list.html

<html>
  <body>
    {% if student_list %}
    <table border>
      <tr>
        <th>USN</th>
        <th>Courses Enrolled</th>
      </tr>
      {% for student in student_list %}
      <tr>
        <td>
          <a href="/p9/student_detail/{{student.pk}}">
            {{ student.student_usn }}
          </a>
        </td>

        <td>
          {% for course in student.enrolment.all %}
          <span>{{ course.course_name }}</span>
          {% endfor %}
        </td>
      </tr>
      {% endfor %}
    </table>
    {% else %}
    <h1>No Students Enrolled</h1>
    {% endif %}
  </body>
</html>

templates/student_detail.html

<h1>Student Name: {{ student.student_name }}</h1>
<h1>Student USN: {{ student.student_usn }}</h1>
<h1>Student Sem: {{ student.student_sem }}</h1>

Program 9

Develop example Django app that performs CSV and PDF generation for any models created in previous laboratory component.

views.py

import csv
from django.http import HttpResponse
from django.shortcuts import render
from .models import Book
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from io import BytesIO

# Create your views here.
def generate_csv(request):
    response = HttpResponse(content_type='text/csv')
    response['Content-Disposition'] = 'attachment; filename="books.csv"'
    writer = csv.writer(response)
    writer.writerow(['Title', 'Author', 'Published Date', 'ISBN'])
    books = Book.objects.all().values_list('title', 'author', 'published_date', 'isbn')
    for book in books:
        writer.writerow(book)
    return response

def generate_pdf(request):
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'attachment; filename="books.pdf"'
    buffer = BytesIO()
    p = canvas.Canvas(buffer, pagesize=letter)
    p.drawString(100, 750, "Book List")
    books = Book.objects.all()
    y = 700
    for book in books:
        p.drawString(100, y, f"Title: {book.title}, Author: {book.author}, Published Date: {book.published_date}, ISBN: {book.isbn}")
        y -= 30
    p.showPage()
    p.save()
    pdf = buffer.getvalue()
    buffer.close()
    response.write(pdf)
    return response

urls.py

from django.urls import path
from . import views

urlpatterns = [
    path('generate_csv/', views.generate_csv, name='generate_csv'),
    path('generate_pdf/', views.generate_pdf, name='generate_pdf'),
]

models.py

from django.db import models

# Create your models here.
class Book(models.Model):
    title = models.CharField(max_length=100)
    author = models.CharField(max_length=100)
    published_date = models.DateField()
    isbn = models.CharField(max_length=13)
    
def __str__(self):
    return self.title

admin.py

from django.contrib import admin
from .models import Book

# Register your models here.
admin.site.register(Book)

Program 10

Develop a registration page for student enrolment as done in Module 2 but without page refresh using AJAX.

views.py

from django.shortcuts import render
from django.http import JsonResponse,HttpResponse
from .forms import StudentForm
from .models import Course

# Create your views here.


def insertcourse(request):
    c1=Course(cid='21CS61',cname='SEPM')
    c2=Course(cid='21CS62',cname='FD')
    c3=Course(cid='21CS63',cname='CG')
    c4=Course(cid='21CS641',cname='AJJ')
    c5=Course(cid='21CS642',cname='DSV')
    for x in [c1,c2,c3,c4,c5]:
        x.save()
    return HttpResponse("insertion of course data successful")

def registration_page(request):
    form = StudentForm()
    return render(request, 'student.html', {'form': form})

def register_student(request):
    if request.method == 'POST':
        form = StudentForm(request.POST)
        if form.is_valid():
            form.save()
            return JsonResponse({'success': True})
        else:
            return JsonResponse({'success': False, 'errors': form.errors})
    return JsonResponse({'success': False, 'errors': 'Invalid request'})

urls.py

from django.urls import path
from .views import register_student,registration_page,insertcourse

urlpatterns = [
    path('course',insertcourse),
    path('register/',registration_page, name='registration_page'),
    path('register_student/',register_student, name='register_student'),
]

models.py

from django.db import models

# Create your models here.
class Course(models.Model):
     cid=models.CharField(max_length=10, primary_key=True)
     cname=models.CharField(max_length=30)
     def __str__(self):
          return self.cname

class Student(models.Model):
    usn=models.CharField(max_length=10, primary_key=True)
    name=models.CharField(max_length=30)
    sem=models.IntegerField()
    courses=models.ManyToManyField(Course)
    

forms.py

from django import forms
from .models import Student, Course

class StudentForm(forms.ModelForm):
    class Meta:
        model = Student
        fields = ['usn', 'name', 'sem', 'courses']
        widgets = {
            'courses': forms.CheckboxSelectMultiple(),
        }
        

admin.py

from django.contrib import admin
from .models import Student, Course

# Register your models here.
class StudentAdmin(admin.ModelAdmin):
    list_display = ['usn', 'name', 'sem']
    list_filter = ['sem']
    search_fields = ['usn', 'name']
    filter_horizontal = ['courses']
    
admin.site.register(Student, StudentAdmin)
admin.site.register(Course)

templates/student.html

<!doctype html>
<html>
    <head>
        <title>Student Registration</title>
        <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
        <script>
            $(document).ready(function () {
                $("#registration-form").on("submit", function (event) {
                    event.preventDefault();

                    $.ajax({
                        url: '{% url "register_student" %}',
                        type: "POST",
                        data: $(this).serialize(),
                        success: function (response) {
                            if (response.success) {
                                $("#message").html(
                                    "<p>Registration successful!</p>",
                                );
                                $("#registration-form")[0].reset();
                            } else {
                                var errors = "";
                                for (var error in response.errors) {
                                    errors +=
                                        "<p>" +
                                        response.errors[error][0] +
                                        "</p>";
                                }
                                $("#message").html(errors);
                            }
                        },
                        error: function (error) {
                            $("#message").html(
                                "<p>An error occurred. Please try again.</p>",
                            );
                        },
                    });
                });
            });
        </script>
    </head>
    <body>
        <h1>Student Registration</h1>
        <div id="message"></div>
        <form id="registration-form" method="POST">
            {% csrf_token %} {{ form.as_p }}
            <button type="submit">Register</button>
        </form>
    </body>
</html>

Program 11

Develop a search application in Django using AJAX that displays courses enrolled by a student being searched.

views.py

from django.shortcuts import render
from django.http import HttpResponse
from .models import Student

# Create your views here.
def courselist(request):
    if request.method == 'POST':
        usn=request.POST['usn']
        try:
            obj=Student.objects.get(usn=usn)
            ans=''
            l=obj.courses.all().values()
            for x in l:
                ans=ans+x['cname']+'<br>'
            return HttpResponse(ans)
        except Exception:
            return HttpResponse('STUDENT USN DOES NOT EXIST/INVALID')
    else:
        return HttpResponse("method is not post")


def course_page(request):
    return render(request, 'course.html')

urls.py

from django.urls import path
from .views import course_page, courselist

urlpatterns = [
    path('course', course_page),
    path('courselist', courselist, name='courselist'),
]

models.py

from django.db import models

# Create your models here.
class Course(models.Model):
     cid=models.CharField(max_length=10, primary_key=True)
     cname=models.CharField(max_length=30)
     def __str__(self):
          return self.cname

class Student(models.Model):
    usn=models.CharField(max_length=10, primary_key=True)
    name=models.CharField(max_length=30)
    sem=models.IntegerField()
    courses=models.ManyToManyField(Course)
    

admin.py

from django.contrib import admin
from .models import Student, Course

# Register your models here.
class StudentAdmin(admin.ModelAdmin):
    list_display = ['usn', 'name', 'sem']
    list_filter = ['sem']
    search_fields = ['usn', 'name']
    filter_horizontal = ['courses']
    
admin.site.register(Student, StudentAdmin)
admin.site.register(Course)

templates/course.html

<!doctype html>
<html>
    <body>
        <h1>Student Course Enrollment Details</h1>
        <div id="message"></div>
        <form id="courseenroll" method="POST">
            {% csrf_token %}
            <label>enter student usn </label>
            <input type="text" id="usn" />
            <button type="submit">check</button>
        </form>
        <p id="ans"></p>
    </body>
    <title>Student Course enrolled details</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        $(document).ready(function () {
            $("#courseenroll").on("submit", function (event) {
                event.preventDefault();

                $.ajax({
                    url: '{% url "courselist" %}',
                    type: "POST",
                    data: {
                        usn: $(usn).val(),
                        csrfmiddlewaretoken: $(
                            "input[name=csrfmiddlewaretoken]",
                        ).val(),
                    },
                    success: function (data) {
                        $("#ans").html(data);
                    },
                    error: function (error) {
                        $("#message").html(
                            "<p>An error occurred. Please try again.</p>",
                        );
                    },
                });
            });
        });
    </script>
</html>

Project

urls.py

"""
URL configuration for project project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.0/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, include

handler400 = ""
urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('program1.urls')),
    path('', include('program2.urls')),
    path('', include('program3.urls')),
    path('', include('program4.urls')),
    path('', include('program5.urls')),
    path('p6/', include('program6.urls')),
    path('', include('scratch.urls')),
    path('',include('scratch4.urls')),
    path('p7/', include('program7.urls')),
    path('p8/', include('program8.urls')),
    path('p9/', include('program9.urls')),
    path('p10/', include('program10.urls')),
    path('p11/', include('program11.urls')),
    path('p12/', include('program12.urls')),
]

settings.py

"""
Django settings for project project.

Generated by 'django-admin startproject' using Django 5.0.6.

For more information on this file, see
https://docs.djangoproject.com/en/5.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.0/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/5.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-az4y$*96^l*o=4h17+j3nf0d@f_$dv$%!35*pxbys$+konmv@x'

# 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',
    'program1',
    'program2',
    'program3',
    'program4',
    'program5',
    'program6',
    'program7',
    'program8',
    'program9',
    'program10',
    'program11',
    'program12',
    'scratch',
    'scratch2',
    'scratch3',
    'scratch4'
]

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 = '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',
            ],
        },
    },
]

WSGI_APPLICATION = 'project.wsgi.application'


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

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


# Password validation
# 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.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/5.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/5.0/howto/static-files/

STATIC_URL = 'static/'

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

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'