Created Assignments App

parent ba2e2cf6
from django.contrib import admin from django.contrib import admin
# Register your models here. from .models import Assignment, Course
class AssignmentAdmin(admin.ModelAdmin):
model = Assignment
list_display = ('name', 'description', 'course', 'perfect_score', 'passing_score',)
class CourseAdmin(admin.ModelAdmin):
model = Course
list_display = ('code', 'title', 'section',)
admin.site.register(Assignment, AssignmentAdmin)
admin.site.register(Course, CourseAdmin)
# Generated by Django 4.1.7 on 2023-03-02 07:00
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Assignment',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(blank=True, max_length=100, null=True)),
('description', models.TextField(blank=True, null=True)),
('course', models.CharField(blank=True, max_length=50, null=True)),
('perfect_score', models.IntegerField(blank=True, null=True)),
('passing_score', models.IntegerField(blank=True, null=True)),
],
),
migrations.CreateModel(
name='Course',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('code', models.CharField(blank=True, max_length=10, null=True)),
('title', models.CharField(blank=True, max_length=100, null=True)),
('section', models.CharField(blank=True, max_length=3, null=True)),
],
),
]
from django.db import models from django.db import models
# Create your models here. class Assignment(models.Model):
name = models.CharField(max_length = 100, blank = True, null = True)
description = models.TextField(blank = True, null = True)
course = models.CharField(max_length = 50, blank = True, null = True)
perfect_score = models.IntegerField(blank = True, null = True)
passing_score = models.IntegerField(blank = True, null = True)
def __str__(self):
return self.name
class Course(models.Model):
code = models.CharField(max_length = 10, blank = True, null = True)
title = models.CharField(max_length = 100, blank = True, null = True)
section = models.CharField(max_length = 3, blank = True, null = True)
def __str__(self):
return self.code
\ No newline at end of file
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name = 'index'),
]
app_name = "assignments"
\ No newline at end of file
from django.shortcuts import render from django.http import HttpResponse
from .models import Assignment, Course
def index(request):
assignmentlist = Assignment.objects.all()
courselist = Course.objects.all()
response = "Widget's Assignment Page"
i = 0
while i < len(assignmentlist):
response += f"<br><br>Assignment Name: {assignmentlist[i].name}" + f"<br>Description: {assignmentlist[i].description}" + f"<br>Perfect Score: {assignmentlist[i].perfect_score}" + f"<br>Passing Score: {assignmentlist[i].passing_score}<br>" + f"Course/Section: {courselist[i].code} {courselist[i].title}-{courselist[i].section}"
i+=1
return HttpResponse(response)
\ No newline at end of file
# Create your views here.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment