Django add extra functionality to Generic DetailView

Hello. In a generic detail view, how do I add extra functionality to the view like only a user with a particular username can view the detail view? Thank you.

Are you saying that only one user can view any of the detail views? Or are you saying that each user can only see one detail view?

If the former, the Django built-in authorization system will handle that for you quite easily.

(Note: If you’re using Class Based Views, you’ll probably also want to read about the PermissionRequiredMixin)

In general, the way you would do this would be to assign the “view_modelname” privilege to a user (or to a group, then make the desired user a member of that group). Then test whether or not the user executing that view has the appropriate permission.

In the latter case, you may need a more general function. There are many ways to do this, I suggest starting with “Limiting access to logged-in users that pass a test

Ken

Ok great, thanks, this helps a lot.