Skip to content
Advertisement

how do i get to show the repeating event details on all following dates in python django

Event Name : Guest Booking Event State date : 1-feb-2022 and event ends on 5-feb-2022. Contact person : ABC Contact number : 12345

When I create this event on 1st of feb and end date will select as 5th of feb, my challenge is, created event should display event name, event date, contact person name and contact number till 5th of feb automatically, without me creating same for 2nd of feb, 3rd of feb till 5th of feb manually.

Advertisement

Answer

You can try

import pprint
from datetime import datetime

data = {
    "event_name": "Guest Booking Event State",
    "from": datetime(2022, 2, 1),
    "to": datetime(2022, 2, 5),
    "contact_person": "ABC Contact",
    "contact_number": "12345",
}
duration = int((data["to"] - data["from"]).days) + 1

for i in range(duration):
    pprint.pprint(data)
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement