GrantU
GrantU

Reputation: 6555

App design with Django and a reporting app

I have 4 applicatiosn in one Django Site:

  1. People App
  2. Car App
  3. Holiday App
  4. Report App

I want to produce reports/charts for app 1,2,3 my question is this...

1) Do I stick to having the report views in each app /people/report, car/report

or

2) Should I just put it all in my report app report/car, report/people etc.

The problem with option 2 is that I have to do a lot of model importing, meaning it could never be independent.

Upvotes: 2

Views: 90

Answers (1)

Wolph
Wolph

Reputation: 80111

In this case I see 3 options:

  1. Has the advantage that it's easier to change the behaviour for a specific chart. I'm just guessing that People might have different types of chart from Cars.

  2. Could be made independent by using generic foreign keys (or something like that).

  3. Create a separate Report app which automatically scans the other apps for a charts.py app (or something similar) just like Django does with models.py. That way you can keep the specific chart configuration in the app which also contains it's model.

    The generic Report app could contain a base class to extend and override from the specific apps.

My vote would go to option 3 since it offers the best from both worlds. Although it might be a bit more complicated to get started, it greatly increases your reusability.

Upvotes: 3

Related Questions