Reputation: 174
I'm trying to return a 404 instead of a 403 when using the PermissionRequiredMixin in a class based view, I don't want a user to see a 403 as then it means the url exists
class SomeobjectCreateView(PermissionRequiredMixin, CreateView):
model = Someobject
success_url = reverse_lazy('some_url')
fields = ['field1', 'field2', ...]
template_name = 'someobjects/someobject_new.html'
permission_required = 'someobjects.permission'
Any ideas?
Upvotes: 1
Views: 370
Reputation: 7330
One way would be custimizing the 403 template
project/urls.py
handler403 = 'your_app.views.handler403'
Now in the 403 view you can render the 404 template.
def handler403 (request, *args, **kwargs):
return render(request, '404.html')
Upvotes: 1