i need improve architecture of site i've built. want achieve within single django project following:
- i want site comes in several versions (one per year), such each version has set of apps related version.
i want keep old versions of site , state of apps in version, still being able add/change/remove apps other version. is, apps may different across versions (models, methods, admin, templates, basically).
i want each app belongs version have data version only. app1 on version 2012 should have 1 database table, , app1 on version 2013 should have another, if same.
it this:
site.com/2012 app1_v1 app2_v1 site.com/2013 app1_v1 app2_v2 (maybe added fields or methods, changed templates) site.com/2014 app1_v2 app2_v2 app3_v1 my current solution rather horrible. when new version of site launched, copy-paste earlier app , have old app is, , adding/modifying new version of app. but, add more apps , more versions come, stupid amount of apps , feels bad design.
how can achieve in django in better way? or @ least, how can structure in better way? think having base model each app, each version inherits from, still makes lot of apps.
as example of app have, may this:
app name: app_v1_2012
model
class bag(models.model) name = models.charfield() class item(models.model) name = models.charfield() in_bag = models.foreignkey(bag) view
class indexview(generic.listview): model = bag template_name = 'sometemplate_2012.html' app name: app_v1_2013
model
class bag(models.model) name = models.charfield() class item(models.model) name = models.charfield() in_bag = models.foreignkey(bag) view
class indexview(generic.listview): model = bag template_name = 'sometemplate_2013.html' app name: app_v2_2014
model
class bag(models.model) bag_name = models.charfield() owner = models.foreignkey(user) class item(models.model) name = models.charfield() in_bag = models.foreignkey(bag) view
class indexview(generic.listview): model = bag template_name = 'sometemplate_2014.html' as can see, biggest problem violation of dry principle. copy-pasted, it's same information.
why don't import models , views previous apps, if library functions? can inherit other classes , add methods , attributes, or override them when necessary. python has lots of oop tools these kinds of situations.
Comments
Post a Comment