diff --git a/studyguides/apps/courses/urls.py b/studyguides/apps/courses/urls.py index 5dd63e1..df7665f 100644 --- a/studyguides/apps/courses/urls.py +++ b/studyguides/apps/courses/urls.py @@ -5,5 +5,5 @@ from . import views app_name = "courses" urlpatterns = [ - -] \ No newline at end of file + path("/", views.subject_view) +] diff --git a/studyguides/apps/courses/views.py b/studyguides/apps/courses/views.py index fad3476..db0d1c7 100644 --- a/studyguides/apps/courses/views.py +++ b/studyguides/apps/courses/views.py @@ -4,5 +4,9 @@ from django import http from django.shortcuts import render, redirect, reverse, get_object_or_404 from .models import Subject, Course, Guide -# Create your views here. + +def subject_view(request, subject_name): + print(subject_name) + subject = get_object_or_404(Subject, url=subject_name) + return render(request, "subject.html", {"subject": subject, "courses": subject.courses.all()}) diff --git a/studyguides/static/base.css b/studyguides/static/base.css index f229bb6..5002eb9 100644 --- a/studyguides/static/base.css +++ b/studyguides/static/base.css @@ -25,6 +25,6 @@ main { margin: 30px; } -.subject { +.color-primary { color: #568ea3; } diff --git a/studyguides/templates/home.html b/studyguides/templates/home.html index e580f4e..e802711 100644 --- a/studyguides/templates/home.html +++ b/studyguides/templates/home.html @@ -4,7 +4,7 @@

{{ subject.name }}

{% for course in courses %} -

{{ course.name }}

+

{{ course.name }}

{% endfor %} {% endfor %} diff --git a/studyguides/templates/subject.html b/studyguides/templates/subject.html new file mode 100644 index 0000000..a32e2b4 --- /dev/null +++ b/studyguides/templates/subject.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} {% block main %} +
+ {% for course in courses %} + +

{{ course.name }}

+ + {% endfor %} +
+{% endblock %} diff --git a/studyguides/urls.py b/studyguides/urls.py index 70f31cd..f70d8f6 100644 --- a/studyguides/urls.py +++ b/studyguides/urls.py @@ -21,12 +21,12 @@ from django.conf.urls.static import static urlpatterns = [ path('admin/', admin.site.urls), - path('courses/', include('studyguides.apps.courses.urls', namespace = 'courses')), - path('auth/', include('studyguides.apps.auth.urls', namespace = 'auth')), + path('auth/', include('studyguides.apps.auth.urls', namespace='auth')), + path('', include('studyguides.apps.courses.urls', namespace='courses')), path('', include('studyguides.apps.home.urls', namespace='home')), - path('', include('social_django.urls', namespace = 'social')), + path('', include('social_django.urls', namespace='social')), ] if settings.DEBUG: urlpatterns.extend(static("static/", document_root=settings.STATIC_ROOT)) - urlpatterns.extend(static("media/", document_root = settings.MEDIA_ROOT)) + urlpatterns.extend(static("media/", document_root=settings.MEDIA_ROOT))