Commit 802e8714 authored by Brescia Amandy's avatar Brescia Amandy

Added list filters and search function to the admin page

parent d250bebc
...@@ -6,9 +6,17 @@ from .models import Assignment, Course ...@@ -6,9 +6,17 @@ from .models import Assignment, Course
class AssignmentAdmin(admin.ModelAdmin): class AssignmentAdmin(admin.ModelAdmin):
model = Assignment model = Assignment
list_display = ('name', 'description', 'course', 'perfect_score', 'passing_score')
search_fields = ('name', 'description', 'course', 'perfect_score')
list_filter = ('name', 'course', 'perfect_score')
class CourseAdmin(admin.ModelAdmin): class CourseAdmin(admin.ModelAdmin):
model = Course model = Course
list_display = ('code', 'title', 'section')
search_fields = ('code', 'title', 'section')
admin.site.register(Assignment, AssignmentAdmin) admin.site.register(Assignment, AssignmentAdmin)
admin.site.register(Course, CourseAdmin) admin.site.register(Course, CourseAdmin)
...@@ -2,9 +2,10 @@ from django.urls import path ...@@ -2,9 +2,10 @@ from django.urls import path
from .views import assignments from .views import assignments
urlpatterns = [ urlpatterns = [
path('', assignments, name='assignments'), path('', assignments, name='assignments'),
] ]
# This might be needed depending on your Django version # This might be needed depending on your Django version
app_name = "assignments" app_name = "assignments"
\ No newline at end of file
...@@ -3,6 +3,7 @@ from django.http import HttpResponse ...@@ -3,6 +3,7 @@ from django.http import HttpResponse
from .models import Assignment, Course from .models import Assignment, Course
def assignments(request): def assignments(request):
return_string = "Widget's Assignments Page<br><br>" return_string = "Widget's Assignments Page<br><br>"
for assignment, course in zip(Assignment.objects.all(), Course.objects.all()): for assignment, course in zip(Assignment.objects.all(), Course.objects.all()):
......
...@@ -16,6 +16,7 @@ Including another URLconf ...@@ -16,6 +16,7 @@ Including another URLconf
from django.contrib import admin from django.contrib import admin
from django.urls import include, path from django.urls import include, path
urlpatterns = [ urlpatterns = [
path('assignments/', include('assignments.urls', namespace="assignments")), path('assignments/', include('assignments.urls', namespace="assignments")),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
......
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