[Django]-Set is_staff to true for new users that created new accounts from CreateView

4👍

You can set is_staff to True in the .form_valid(…) method:

class SignUpView(generic.CreateView):
    form_class = SignUpCustomUserForm
    success_url = reverse_lazy('login')
    template_name = 'registration/signup.html'
    
    def form_valid(self, form):
        form.instance.is_staff = True
        return super().form_valid(form)

Leave a comment