Restrict a user from creating more than a MAX number of halls

How do I restrict a user from creating more than a MAX number of halls ?

MAX_HALLS = 10
class CreateHall(LoginRequiredMixin, generic.CreateView):
    model = Hall
    
    """
    if user has reached MAX_HALLS then 
    template_name = 'halls/restrict_hall.html'
    """

    fields = ['title']
    template_name = 'halls/create_hall.html'
    success_url = reverse_lazy('dashboard')

    def form_valid(self, form):
        form.instance.user = self.request.user
        super(CreateHall, self).form_valid(form)
        return redirect('dashboard')
    def get(self, request, *args, **kwargs):
        if Hall.objects.filter(user=request.user).count() > MAX_HALLS:
            return render(request, 'halls/restrict_halls.html')        

        return render(request, self.template_name, {'form': HallForm()})

Yep! That seems like a fine way to do that :smiley: