My project consists of two versions of the same thing. For example version 1 is Freshman and version 2 is Sophomore. To avoid redundancy I am using the same templates and views as the implementation in both the version is not very different. The only difference in this site would be in the urls. Such that
localhost:8000/freshman/computer-science
localhost:8000/sophomore/computer-science
The user of my site can switch to any version of the site by just clicking on a button namely Freshman or Sophomore. I am confused about HOW TO implement such a method through which I would not have repeat myself and can achieve the functionality in a pythonic way.
There are a many method’s through which this functionality can be achieved using the django framework. One way that I can suggest right now is by using django session
The complete documentation of sessions is available HERE
You can keep a variable in sessions, let call it type. When the user clicks on Freshman the type would be ‘f’ or ‘s’ in the later case. So
To get which type is being used for the site, simply
” would be in the case when a user has not clicked on any of the two options.
Though this is a very simple and applicable way but to be honest I am not a big fan of using session, therefore, I would be anxious to see more methods to be listed.