0

I have the following design considerations:

  • I have 4 groups of users students, parents, teachers and administrators.
  • Students, parents, teachers shares the same relationship information - classes, parent-children, teachers-classes etc.
  • The teachers have a "portal" whereby they perform some tasks that are visible to only the teachers, but also publishes some information that distributes to the other type of users.
  • Similarly, parents and students can login to view shared information but may also have features that is particular to themselves only.
  • Administrators adds/edits new users, changes classes of students etc, and can make portal-wide announcements.
  • Prensentation layout of each "portal" should be similar

Currently, I thought of the following

  • Root
    • teachers
      • apps
      • urls,etc
    • parents
      • apps
      • urls,etc
    • common_apps
    • administrators (Django-admin site)

teachers, parents and administrators are separate django projects. Common apps houses information that all types of users share. teachers.apps have apps that may act on apps in common_apps. Administrator is basically a admin site.

Is this structure suitable for the above requirements? Are permissions going to be a problem with this layout? Please let me feed on your experiences and offer some advices.

1
  • These should all be in a single project. Oct 26, 2011 at 16:18

2 Answers 2

0

Create just one app, and use proxy models for Student, Parent and Teacher, each inheriting from User. Create and use groups to distinguish between them, e.g. students will be Users belonging to a "Student" group.

class StudentManager(models.Manager):
    def get_query_set(self, *args, **kwargs):
        qs = super(StudentManager, self).get_query_set(*args, **kwargs)
        return qs.filter(groups__name='Student')

class Student(User):
    objects = StudentManager()

    class Meta:
        proxy = True

Rinse and repeat with Parent and Teacher.

Use signals to auto-set the groups:

from django.db.models.signals import post_save
from django.dispatch import receiver

@receiver(post_save, sender=Student)
def set_student_group(sender, instance, created, **kwargs):
    if created:
        group, c = Group.objects.get_or_create(name='Student')
        instance.groups.add(group)

Rinse and repeat for Parent and Teacher.

Now, create a user profile model:

class UserProfile(models.Model):
    user = models.OneToOneField(User)
    # Other data

In settings.py:

AUTH_PROFILE_MODULE = 'yourapp.UserProfile'

That should give you all the infrastructure you need. You can continue to extend the Student, Parent and Teacher models with additional functionality. You just can't add new fields to them; all additional fields should go on UserProfile.

Administrators and only administrators should be given access to the Django admin (User.is_staff=True). From there, they can do all the requisite management. You should develop a frontend system to cater to the students, teachers and parents.

2
  • in your opinion, "You should develop a frontend system to cater to the students, teachers and parents", should it be a single project or 1 project per user group, because like I mentioned, some features/information are shared while others are exclusive. Hence I'm not sure if one set of urls, settings is sufficed.
    – goh
    Oct 27, 2011 at 3:47
  • A "project" is a very, very broad concept. It can be a whole website or even a cluster of websites. You should never have separate projects unless you're truly dealing with two things that are so different they have no relation to each other at all. You may have separate apps, but in your scenario, I don't even see that as a necessity. All of the functionality could be lumped into one single app within one single project. Oct 27, 2011 at 17:25
0

I think that your app structure is a bit confusing. From my point of view, you could use something similar to:

  • Only one django project. If this will be a unique portal, you should merge all into only one django project.
  • Create all your apps inside this project: subjects, timetables.. everything you need.
  • Extend User model for parents, students, teachers. You can use groups and permissions for handle the information of each one.

This structure also allow you to have the same "layout" for all sections.

Check django documentation for User models and Profiles, it will help you.

Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.