Thanks in advance for bearing with me, still quite new to Django & dev in general.
Bit of context: maintenance/update/evolution of a pre-existing app coded by a third party. The app aims at managing courses, students, teachers, and a variety of school-related needs.
Details
We have a “Profile” model linked to our users, meant to store various information, that i’d like to make more generic and flexible.
We currently have this “Profile” model (with various student-specific fields), and another distinct “TeacherProfile” model, sharing many common attributes, both linked to Django users (“User” model).
But I think it would make more sense to have a more generic “Profile” model with a restricted set of fields (the ones that apply to all our user types) and then have complimentary custom “StudentProfile” and “TeacherProfile” holding their respective specific fields. We are also in a situation where a student can become a teacher, a teacher become a student, and can be both at the same time.
So I am contemplating use of model inheritance (by having Student/TeacherProfile inheriting from the base “Profile”), but am unsure if it would be a proper use, as it raises various…
Questions
- Is this a good approach overall ? Or should I rather stick to standalone models with OneToOne links, considering I want to be able to dynamically add/remove the Student/Teacher portions as the user evolves?
- If viable, I’ll have to create new “StudentProfile” objects, but will need to have them linked to their existing “Profile” instead of a new one. Is that possible ? If yes, how ?
One of my secondary goals (and interest for inheritance) is to further develop our “alumni” status (past students), by creating an “AlumniProfile” model as a child of “StudentProfile”. One of the main goals would be to “move” links to exam results and past courses from the “StudentProfile” to the "AlumniProfile"upon completion of a training/study cycle. As we do have returning students, this would help distinguish between current and past cycles.
Of course, if any of the above is plagued by misconceptions on Django, Python, or anything else, please do point those out. Many thanks for your time already !