views:

75

answers:

2

I'd like to extend/subclass admin Groups & Users classes in Django.

  • CourseAdmin group should be doing what admin can do, and they have extra information like email, phone, address.
  • CourseAdmin should be able to create CourseAdmins, Teachers, Courses and Students.
  • Teacher should be able to edit courses and students belong to them. They can't create anything new.

I want to make use of current Django admin classes Group & User instead of doing my own. Please kindly advise. Thank you!

+1  A: 

You can't both extend and use the existing ones. Use a OneToOneField instead.

Ignacio Vazquez-Abrams
+1 Thanks Ignacio. You helped me a few times today. Could you please explain why can't I? I can unregister the "User" right? Moreover, I want Teachers able to login to the admin back-end but limit their rights to editing certain tables only.
Viet
@Viet: Everything you should need to know is described in the documentation: http://docs.djangoproject.com/en/1.1/topics/auth/
Felix Kling
There's no need to waste your time unregistering anything. Just use the built-in permissions system.
Ignacio Vazquez-Abrams
Hi Ignacio, could you please give me example snippet. I'm trying without luck for hours. Thanks.
Viet
+1  A: 

Do you mean that the whole group CourseAdmin has one email, phone and address? I doubt that.

Otherwise you don't have to subclass anything. Just create a user profile model (that includes e.g. email, phone, address), create the groups: CourseAdmin, Teacher, Students and set up the permissions accordingly.

You can distinguish the users by checking in which group they are in.

More about user authentication.

Felix Kling
+1 Thanks Felix. I mean that each user in CourseAdmins and Teachers group have own email, phone and address. Teachers have access to all tables. Teachers have access to certain tables and certain rows (courses and students that belong to that Teacher).
Viet