mirror of
https://github.com/tjsga/studyguides.git
synced 2025-04-05 03:40:16 -04:00
Create subject view, update styling
This commit is contained in:
parent
6105a077b7
commit
62b7273bab
|
@ -5,5 +5,5 @@ from . import views
|
||||||
app_name = "courses"
|
app_name = "courses"
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
path("<str:subject_name>/", views.subject_view)
|
||||||
]
|
]
|
||||||
|
|
|
@ -4,5 +4,9 @@ from django import http
|
||||||
from django.shortcuts import render, redirect, reverse, get_object_or_404
|
from django.shortcuts import render, redirect, reverse, get_object_or_404
|
||||||
|
|
||||||
from .models import Subject, Course, Guide
|
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()})
|
||||||
|
|
|
@ -25,6 +25,6 @@ main {
|
||||||
margin: 30px;
|
margin: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.subject {
|
.color-primary {
|
||||||
color: #568ea3;
|
color: #568ea3;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<h2>{{ subject.name }}</h2>
|
<h2>{{ subject.name }}</h2>
|
||||||
|
|
||||||
{% for course in courses %}
|
{% for course in courses %}
|
||||||
<p class="subject"><a href="/{{subject.url}}/{{course.url}}"/>{{ course.name }}</a></p>
|
<p class="color-primary"><a href="/{{subject.url}}/{{course.url}}"/>{{ course.name }}</a></p>
|
||||||
|
|
||||||
{% endfor %} {% endfor %}
|
{% endfor %} {% endfor %}
|
||||||
</main>
|
</main>
|
||||||
|
|
9
studyguides/templates/subject.html
Normal file
9
studyguides/templates/subject.html
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{% extends "base.html" %} {% block main %}
|
||||||
|
<main>
|
||||||
|
{% for course in courses %}
|
||||||
|
|
||||||
|
<p class="color-primary"><a href="/{{subject.url}}/{{course.url}}"/>{{ course.name }}</a></p>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
</main>
|
||||||
|
{% endblock %}
|
|
@ -21,12 +21,12 @@ from django.conf.urls.static import static
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
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('studyguides.apps.home.urls', namespace='home')),
|
||||||
path('', include('social_django.urls', namespace = 'social')),
|
path('', include('social_django.urls', namespace='social')),
|
||||||
|
|
||||||
]
|
]
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
urlpatterns.extend(static("static/", document_root=settings.STATIC_ROOT))
|
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))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user