Reputation: 6555
I have 4 applicatiosn in one Django Site:
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
Reputation: 80111
In this case I see 3 options:
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.
Could be made independent by using generic foreign keys (or something like that).
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