Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the Django scheduler app with your own models

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?

like image 305
Sem Avatar asked Jun 20 '14 12:06

Sem


2 Answers

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.

like image 36
Don Avatar answered Sep 18 '22 23:09

Don


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

like image 129
cchristelis Avatar answered Sep 20 '22 23:09

cchristelis