Reputation:
I am currently brainstorming about building an existing PHP CodeIgniter project in Django. I spit through the documentation a bit already and done some online tutorials to test how it works and am really charmed by it.
The theoretical design issue I'm currently facing is that in what I have in mind; Apps will be dependent on each other, yet the Django documentation itself states that it Apps should be pluggable.
The thing is that I have a Products App with different sub-properties like colors, groups, models (foreign key relationships). Now I started thinking on how to use my Invoices App, but I instantly notice that the Invoices App will need products from the Products App.
I wonder how other people do this in their Django projects? Would I need to rethink the way I design my whole application (Products, Invoices, Orders, Deliveries, Email, etc.) and how they are linked individually?
Would I tell Django that my Invoices App needs my Products App to be initialized , or do I totally remodel the situation having something like an ERP App that house all those parts as their own Models?
In the end I want to have my front-office to also be converted to Django (Webshop) and access my back-office (ERP) products. I also wonder how I would incorporate that then.
Upvotes: 0
Views: 213
Reputation: 174624
I am not really sure what you are asking, but here are some tips, based on some hard-learned lessons.
Apps should do one thing, and one thing only. If you can't describe what your app does without three or four "ands" in the sentence, you need to rethink your app.
Models are tied to apps; but this doesn't mean you can't use models from app A, in app B. A model by itself is not an app; you can't say "Products app with different sub-properties".
You can have apps that have models but no views if that's what's required. There is no requirement that an app must serve a view.
Keep your views simple, your models rich, and for your application you'll probably have lots of utility scripts that serve as helpers, this is fine and encouraged. You don't want lots of complicated logic in your views, and you really don't want lots of logic in your templates.
When the django documentation states that apps are pluggable, what it means is that application should be standalone; all their required dependencies (templates, urls, views, models) should be encompassed together with the app such that you can publish it and people can download and integrate your app with minimal impact. The release of 1.5 brought a new section in the tutorial how to write reusable apps which should provide more insight.
I would argue that a good pluggable app is one that can easily be 'chained together' to solve a problem.
Upvotes: 2