0

I am implementing a project using Django. It's a site where people can view different Art courses and register. I am having trouble implementing the app as reusable applications. I already have a standalone App which takes care of all the aspect of Arts. Now I want to create another application where an admin create various events for the Arts in the system. conceptually these two should be a standalone apps. Event scheduling is pretty general use case and I want to implement in a way where it can be used for scheduling any kind of Event.

In my case, those Events are Art related events. I don't want to put a foreign key to Art model in my Event model. how can I make it reusable so that it would work for scheduling Events related to any kind of objects.

j08691
  • 204,283
  • 31
  • 260
  • 272
sanket
  • 93
  • 1
  • 7
  • 1
    If you create a `ArtEvent` model and add relations between `Art` and `Event` models, then you could create a `Event` specific app to create events and with some manipulations you can have everything linked. – Jean Jung Aug 24 '15 at 18:58
  • thanks Jean, I think it makes sense. – sanket Aug 25 '15 at 18:32

1 Answers1

1

My sugestion is to create a third model, called ArtEvent and make this model points to Art and Event, this way you can create an especific app to manage events and then link everything. For example, when creating a new ArtEvent you redirects the user for the Event app, to enable him to create a new event. Then redirects again to the Art app with the created event, create a new ArtEvent and links those objects.

In future lets suppose that you want to add events to another model, like User, if you follow the same strategy you can separate what is UserEvent specific, and maintain what is common between ArtEvent and UserEvent.

Jean Jung
  • 1,200
  • 12
  • 29
  • thanks Jean, I think I could contenttypes module as well. it lets you connect models in a generic manner. what do you think about it ? – sanket Aug 25 '15 at 20:32
  • I never used it, but looks good, if you are familiar with it you can try. Just take caution and looks where you are stepping, if the things become too hard to do, it's wrong, our philosophy is, "The things must be simple and easy, if not, it's wrong". And remember, always take a look at the Zen of Python and check with what you are doing, then you will be OK! – Jean Jung Aug 26 '15 at 20:15