On Thursday 26 January 2017 12:10:07 Mike08 wrote:

> Now each teacher (Teacher model) is assigned a Subject (subject
> Model). Now each Teacher should have an admin section they should not
> be able to change their name, they should not be able to change their
> subject but they can create new topics that they would like to
> discuss in their class(Topic Model). My question is what would be the
> best approach to handle this.
> 
> Example:
> 
> *class Subject(models.Model):*
> *    name = models.CharField(max_length=200)*
> *    text   = models.CharField(max_length=200)*
> 
> *class Topic(models.Model)*
> *    topic_name = models.CharField(max_length=200)*
> 
> *class Teacher(models.Model):*
> *    name = models.CharField(max_length=200)*
> *    subject= models.ForeignKey('Subject')*
> *    topic= models.ForeignKey('Subject')*
> *    text = models.TextField()*
> 

This is explained in the docs, but tucked away[1]. Also review the contrib.auth 
part 
about Permissions and Authorization[2].
In short, by creating the proper groups and sticking the users in there, one 
can assign 
the basic CRUD permissions per object.
Finer-grained control can be achieved with custom permissions[3] and the 
user_passes_test decorator[4].
-- 
Melvyn Sopacua

--------
[1] 
https://docs.djangoproject.com/en/1.10/ref/contrib/admin/#django.contrib.admin.Mode
lAdmin.has_change_permission
[2] 
https://docs.djangoproject.com/en/1.10/topics/auth/default/#permissions-and-authorization
[3] 
https://docs.djangoproject.com/en/1.10/topics/auth/customizing/#custom-permissions
[4] 
https://docs.djangoproject.com/en/1.10/topics/auth/default/#limiting-access-to-logged-in-users-that-pass-a-test

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/11011795.Mc3Qptr46z%40devstation.
For more options, visit https://groups.google.com/d/optout.

Reply via email to