[Solved]-Creating Reusable Django Apps?


In this case, personally, I’d keep it simple and just leave rating on the model. You have to balance re-usability with simplicity of implementation. It’s great to make things reusable, but is your Movie model really useful enough to warrant the extra work? And is it that bad to have a dependency? I think much of these design decisions are subjective. There was a good talk this year at PyCon on this subject: http://blip.tv/file/4882961


First, I agree with zeekay above, you should introspect whether that amount of re-usability is worth it, for your model.

If it indeed is, you can create a new movierating app that has a RatingModel that has FK to movies.models.Movie and the rating field.

You will never-the-less pass the rating somehow to the the templates. For that, you can create class-based-views and in the movierating.views you can extend and override the get_context method.

Don’t forget achieving reusability is a fundamental value judgement that a developer has to make and over-doing it could be as bad as the not doing it in the first place.



Having dependencies is not necessarily a bad thing. For something like a field (rating, timedelta, JSON object), where there is no builtin field that does what you need, having to include a seperate app that handles that (and perhaps some related functionality, like template tags) is a feature, not a bug.

More of an issue is when your apps’ models reference models from other apps. Of course, this happens in the real world, but in that case, it makes it much harder to identify isolated models.

Leave a comment