[Django]-How to clear some warning messages using Django and Python

9👍

It’s a trival fix. Your doc strings are misplaced. They should look more like this:

class Signup(View):
    """ this class is used for user signup """

    def get(self, request):
        """ this class is used for user signup """
        form = UserCreationForm()
        return render(request, 'booking/signup.html', {'form': form})

    def post(self, request):
        """ this function used for post the sign up data """
        form = UserCreationForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect('login')

E: 34,11: Instance of ‘AuthenticationForm’ has no ‘is_valid’ member (no-member)

As for this one , pylint is clearly mistaken (assuming of course that your AuthenticationForm is a sublcass of forms.Form)

R: 28, 4: Method could be a function (no-self-use)

If you are wondering about this, pylint thinks that get and post shouldn’t be methods of Signup. That’s because you are not using the self parameter that is required to be the first parameter of any method in a class. But once again pylint is clearly wrong because class based views work exactly like this. You might want to customize your pylint installation for django. or add this

def get(self, request):  #pylint disable=no-self-use
👤e4c5

Leave a comment