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.
我正在使用Django实现一个项目。这是一个人们可以查看不同艺术课程并注册的网站。我无法将应用程序实现为可重用的应用程序。我已经有一个独立的应用程序,它负责艺术的所有方面。现在我想创建另一个应用程序,其中管理员为系统中的Arts创建各种事件。从概念上讲,这两个应该是一个独立的应用程序。事件调度是非常通用的用例,我希望以一种可用于调度任何类型事件的方式实现。
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.
就我而言,这些活动是与艺术有关的活动。我不想在我的Event模型中为Art模型添加外键。如何使其可重用,以便它可以用于调度与任何类型的对象相关的事件。
1 个解决方案
#1
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.
我的兴趣是创建第三个模型,称为ArtEvent,并使此模型指向艺术和事件,这样您就可以创建一个特定的应用程序来管理事件,然后链接一切。例如,在创建新的ArtEvent时,您将用户重定向到Event应用程序,以使他能够创建新事件。然后使用创建的事件再次重定向到Art应用程序,创建一个新的ArtEvent并链接这些对象。
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
.
将来假设您想要将事件添加到另一个模型(如User),如果您遵循相同的策略,您可以分离特定于UserEvent的内容,并维护ArtEvent和UserEvent之间的共同点。
#1
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.
我的兴趣是创建第三个模型,称为ArtEvent,并使此模型指向艺术和事件,这样您就可以创建一个特定的应用程序来管理事件,然后链接一切。例如,在创建新的ArtEvent时,您将用户重定向到Event应用程序,以使他能够创建新事件。然后使用创建的事件再次重定向到Art应用程序,创建一个新的ArtEvent并链接这些对象。
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
.
将来假设您想要将事件添加到另一个模型(如User),如果您遵循相同的策略,您可以分离特定于UserEvent的内容,并维护ArtEvent和UserEvent之间的共同点。