Add a New Assignment page has been created

parent 6c533cdf
from django import forms
from .models import Course, Assignment
class CourseForm(forms.ModelForm):
class meta:
model = Course
fields = ['code', 'title',
'section']
class AssignmentForm(forms.ModelForm):
class meta:
model = Assignment
fields = ['name', 'description',
'course', 'perfect_score']
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} Add Assignment {% endblock %}
{% block content %}
<h1>Add a New Assignment</h1>
<form action="" method="post">
{% csrf_token %}
{{ form }}
<input type="submit" value="Save New Assignment">
</form>
{% endblock %}
\ No newline at end of file
......@@ -11,7 +11,7 @@
</li>
{% endfor %}
</ul>
<button>
<button onclick="window.location.href='../../Assignments/add/';">
New Assignment
</button>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import (AssignmentView,
AssignmentsDetailView)
AssignmentsDetailView, AssignmentsCreateView)
urlpatterns = [
path('assignment/', AssignmentView, name="index"),
path('<pk>/details/', AssignmentsDetailView.as_view(), name='assignment-details')
path('assignments/', AssignmentView, name="index"),
path('<pk>/details/', AssignmentsDetailView.as_view(), name='assignment-details'),
path('add/', AssignmentsCreateView.as_view(), name='assignment-add'),
]
app_name = "Assignments"
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Assignment, Course
# Create your views here.
......@@ -13,6 +14,11 @@ class AssignmentsDetailView(DetailView):
model = Assignment
template_name = 'Assignments/assignment-details.html'
class AssignmentsCreateView(CreateView):
model = Assignment
fields = '__all__'
template_name = 'Assignments/assignment-add.html'
'''
def index(request):
head_string = "<h1>Widget's Assignment Page</h1>"
......
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