8

Using the https://github.com/llazzaro/django-scheduler I'd like to use my own models in the calendar, they also have a start and end date.

I think there are multiple ways to solve this problem:

  1. Hack the current schedule app to make it interact with my models.
  2. Creating default event models when creating my models, using the save() override.
  3. Use the "relations of events to generic objects" feature of the django-scheduler app.
  4. Extend the default event models to meet my own requirements.

I would like to use the third option but I wouldn't know how to use it since a calendar is linked to a single object.

I'm new to both Python and Django, so could someone give me advice?

Don
  • 16,928
  • 12
  • 63
  • 101
Sem
  • 4,477
  • 4
  • 33
  • 52
  • So @llazzaro, I have used the third option and subclassed the Event class. But it starts at a particular time on the first day, say 10 am. It is hsown as an "all day" event for the intermediate days and ends at 5pm on the last day. I wanted to understand whether I can get a one-time event across a number of days that starts at the same time and ends at the same time every day. – Afrowave Aug 27 '16 at 10:11

2 Answers2

4

To achieve option 3, your generic object would have a foreign key linking to an Event object from that calendar app.

cchristelis
  • 1,985
  • 1
  • 13
  • 17
  • So basically option 3 and 4 are the same huh. It doesn't generate a completely new table? – Sem Jun 20 '14 at 12:30
  • From a table point of view option 4 would imply changing the Event table to look like what you want. Option 3 implies creating a new table with your generic object as well as a table with the links between the two tables. But ito what you should do is option 3, since otherwise you need to take over maintenance etc. of this calendar app. – cchristelis Jun 20 '14 at 12:37
  • I guess you are right. I have made an Event subclass and it works flawlessly. Still need to create a way to make the events link to a specific page but that's another concern. Thanks for the help! – Sem Jun 20 '14 at 12:41
  • agree on using option 3! – llazzaro Jul 26 '14 at 19:59
  • @llazzaro can settings.SCHEDULER_BASE_CLASSES do the job? – Don May 03 '17 at 10:50
2

Django Scheduler has a quite hidden setting (not even reported in official docs) which can do the trick:

SCHEDULER_BASE_CLASSES

SCHEDULER_BASE_CLASSES = {
    'Event': ['my_app.models.EventAbstract1', 'my_app.models.EventAbstract2']
    'Calendar': [my_app.models.CalendarAbstract']
}

So, you can define your own abstract model and make Calendar extend it.

EDIT

As @Jheasly said in his comment, this feature is now documented.

Don
  • 16,928
  • 12
  • 63
  • 101
  • 1
    Looks like `SCHEDULER_BASE_CLASSES` was [added to the docs](http://django-scheduler.readthedocs.io/en/latest/settings.html#scheduler-base-classes) in this [June 25, 2017, commit](https://github.com/llazzaro/django-scheduler/commit/4f4ea9ad8d6c8301f181e0180a56b8fa953b6bce). – Jheasly Jul 25 '17 at 01:59
  • Yes, I opened an issue just after posting this answer – Don Jul 25 '17 at 04:30
  • 1
    Ah. Wull, that makes sense! : ) – Jheasly Jul 26 '17 at 00:12
  • didn't SCHEDULER_BASE_CLASSES removed as of version 0.8.7? https://github.com/llazzaro/django-scheduler/blob/develop/CHANGELOG#L73 – xjlin0 Sep 17 '22 at 17:57