PacktPublishing / Django-4-by-example

Django 4 by example (4th Edition) published by Packt
https://djangobyexample.com/
MIT License
818 stars 461 forks source link

Question about dealing with an educa course with no modules #32

Open gavin-dev21 opened 1 year ago

gavin-dev21 commented 1 year ago

Hello,

I have been noticing an issue in cases where a student tries to enroll in a course with no modules. When this occurs I receive a "list index out of range" error pointing to:

context['module'] = course.modules.all()[0]

I was wondering if there was an elif statement or some other solution to this issue that I missed?

Thank you.