How to use django-scheduler application in an existing application

I am looking for django applications for handling events like Event Calendar, and the django-schedule sample project provides a sample project, but I do not know how to map the Task class (title and startTime) to the django graph event class. The documentation does not make it clear how I can do this? It will really be apprciate if some pointers or steps can be provided here to use the django-schedule application with an existing application

The solution is here. Using the Django scheduler application with your own models is present, but I can't do much. I am looking for a tutorial on how to connect django-scheduler to my own model.

+5
source share
1 answer

Found this good conversation on the Internet https://groups.google.com/forum/#!topic/pinax-users/9NoRWjMdiyM , and the logic will be explained as a reference, as shown below:

  • Suppose your task class has startDateTime and endDateTime and Title
  • from schedule.models import Event, EventRelation, Calendar (from Schedule application)
  • Cancel the method of saving the Task object to create a new event, as shown below, change the code specified in the link above to make it more understandable.
  • The code searches for an existing Calendar and attaches an event to it that is associated with the Task object through a relationship
  • Tried the code below to extend the Project-Sample application that comes with the source and it works great

    def save(self, force_insert=False, force_update=False): new_task = False if not self.id: new_task = True super(Task, self).save(force_insert, force_update) end = self.startDateTime + timedelta(minutes=24*60) title = "This is test Task" if new_task: event = Event(start=self.startDateTime, end=end,title=title, description=self.description) event.save() rel = EventRelation.objects.create_relation(event, self) rel.save() try: cal = Calendar.objects.get(pk=1) except Calendar.DoesNotExist: cal = Calendar(name="Community Calendar") cal.save() cal.events.add(event) else: event = Event.objects.get_for_object(self)[0] event.start = self.startDateTime event.end = end event.title = title event.description = self.description event.save() 

Still, you need to look for the Click function extension in the Calendar event, which currently provides a text field, how to configure it with a hyperlink is not yet visible, but the code above answers the question and part of the problem.

+3
source

Source: https://habr.com/ru/post/1208095/


All Articles