Im attempting to display all the course Names in my Course Model,
{% for course in object_list%}
<li>{{ course.courseName}} </li>
{% endfor %}
</ol>
Heres a snippet from the HTML page Im trying to display them in.
here's my models.py
# Create your models here.
SEMESTER_CHOICES = (
("SPR 21", "SPR 21"),
("FA 21", "FA 21"),
("SPR 22", "SPR 22"),
("FA 22", "FA 22"),
("SPR 23", "SPR 23"),
("FA 23", "FA 23"),
("SPR 24 ", "SPR 24"),
("FA 24", "FA 24"),
)
PROGRAM_CHOICES = (
("Architectural Science","Architectural Science"),
("Civil Engineering","Civil Engineering"),
("Computer Information Technology","Computer Information Technology"),
("Computer Science","Computer Science"),
("Construction Management","Construction Management"),
("Electrical Engineering","Electrical Engineering"),
("Engineering Technology Management","Engineering Technology Management"),
("Manufacturing Engineering","Manufacturing Engineering"),
("Mechanical_Engineering","Mechanical_Engineering")
)
# declaring a Student Model
class AddCourse(models.Model):
program = models.CharField(
max_length = 20,
choices = PROGRAM_CHOICES,
default = 'Architecural Science'
)
courseName = models.CharField(max_length=250)
semester = models.CharField(
max_length = 20,
choices = SEMESTER_CHOICES,
default = 'SPR 21'
)
preRequisites = models.TextField()
def __str__ (self):
return self.courseName
and here is my views.py
from django.shortcuts import render
from .models import AddCourse
from django.contrib.auth.decorators import login_required
# Create your views here.
@login_required
def currentpathway(request):
return render(request, "SEAS_Course_Planner/home.html")
@login_required
def newpathway(request):
return render(request, "SEAS_Course_Planner/newpathway.html")
Nothing is printing out and I believe the object list is empty, but I've added courses via the admin page, any suggestions. Im new to Django as you can tell hahaha.
{% for course in object_list%}must be{% for course in object_list %}- the empty space before%is important, isn't it?