Liam Hanninen
Liam Hanninen

Reputation: 1573

How to add onClick actions to calendar events using Django-Scheduler?

I'm using Django-scheduler in my project. I really like the calendar and the ability to create recurring events.

After installing it the the only code (besides stuff in settings.py) I've added is to myproject/urls.py:

url(r'^schedule/', include('schedule.urls')),

I then created a calendar called testcalendar and an event called Test Event in /admin. I then traversed to http://127.0.0.1:8000/schedule/calendar/month/testcalendar/. And woo who! - I see the event and my calendar. The template it uses is schedule/calendar_by_period.html which extends base.html - which is also nice. I can move forward and backward in months and select alternate calendar views (tri-month, year, etc)...nice!

enter image description here

I've gotten all of this functionality by simply adding that single line in urls.py but I don't think I can get away with that any more. I can't understand if the documentation explains how to incorporate it further into an existing project.

Specifically, I want to add an action when the user clicks on the test event (see screenshot). The only way I can do this now is by modifying the source code to add some jQuery in schedule/calendar_by_period.html. But adding JQuery there or in base.html to catch the calendar event would be pretty tricky anyway since the div and button generated for calendar events don't have unique ids or classes. Plus I doubt that's the intention of the creators.

Do I create custom url paths that point to my own view that inherits from CalendarByPeriodsView? If so I still don't have access to the template. Do I just copy and paste the template and add it locally to my project templates? That seems wrong too.

Upvotes: 2

Views: 1263

Answers (0)

Related Questions