-3

How can i give the user 1 times permission to access the page(like a exam page). There is a one problem. When i resize page, its must be reload. Also when he goes to another page couldnt return the exam page like with back button or try to return from url. like a page -> b page x- a page

1 Answers1

0

Your question is really too broad and lacks code and other specifics to allow for a particularly helpful answer - see how to ask.

However, to give you a steer, if you have a particular model (such as an exam, in your case) then I would create a many-to-many field that tracks which users have accessed the page.

class YourExamModel(models.Model)
    ...
    viewed_by = models.ManyToManyField(User, ...

You can then use this field to determine whether a user has already accessed the page. If so, redirect them elsewhere (or show a particular message) otherwise display the page as normal.

def your_view(request):
    exam = YourExamModel.objects.get(...
    if request.user in exam.viewed_by.all():
        return redirect('go-somewhere-else')
    ...

    # track that the user has accessed the exam
    exam.viewed_by.add(request.user) 
    return render(request, 'exam.html', context)

To the point about not letting the user go back a page, here is a similar question that might help you.

0sVoid
  • 2,547
  • 1
  • 10
  • 25