views:

303

answers:

1

I'm working on a project that has several apps, and want to include a news app for news stories.

However, I'd like to link news stories to objects in my custom app, but use an open source news app to run the news.

At the moment I've simply hacked the chosen news app to add in a ForeignKey relationship with my model.

i.e. a widgets app, with a widget model

then a news app with the entry model linked directly to my widget model

Is there a better way to do this? because if I want to update the news app with the latest version of it, it'll obviously overwrite my hack.

I could have the link from my custom model, but the workflow should really be

  1. Add news article
  2. choose a widget to link it to

NOT

  1. Add a news article, save
  2. Find the widget to link it to
  3. Link back to the news article
+4  A: 

I think you could have a model which inherits from the model in the external app. Something along the lines of:

MyNewsArticle(ExternalAppNewsArticle):
    object = models.ForeignKey(MyObject)

As long as you're adding things rather than dropping things, this should work. You have to be careful if the model from the external app has any Custom Managers declared though, because by default Django will not inherit them. You might need to declare them again in your own model.

Monika Sulik
that makes sense. cheers
Guy Bowden