I have a Django model called Event that has a date field for the date of the event:
class Event(models.Model):
event_date = models.DateField()
I’d like to be able to set a method on the model to tell whether the event is a “spring semester” event or a “fall semester” event.
The spring semester would be defined as January to May. Fall is August to December.
My goal is to be able to filter by either semester in a generic list of events for a year.
How would I go about writing the method defining each semester?
One approach is:
Then in a view you can do:
Hope that helps you out.