Django- restrict users to access urls

Viewed 4740

i'm creating a app.it has manytomany field to store data about class and students.

urls.py

url(r'^class/(?p<title>[-\w]+)/(?p<id>[\d]+)/',views.list,name ='list'),

Basically one user(Teacher) can create many class_room .Each class_room have one title and many students following in that class.

problem is:

Each class_room have unique url. Eg (mywebsite.com/science/88/) this link is access only for following students not for anonymous user.This is a loop hole if any non following students try some random url like this they could see the page (mywebsite.com/maths/2500/).

How to restrict a student from access a page which he is not following?

1 Answers
Related