get_success_url() takes exactly 3 arguments (2 given)

后端 未结 3 860
执念已碎
执念已碎 2021-01-28 05:58

every one ,, I am using

django-registration-redux (1.4)

for my django registration(django 1.8),,however ,,when never I registered th

相关标签:
3条回答
  • 2021-01-28 06:35

    In django-registration-redux RegistrationView has get_success_url defined as this.

    def get_success_url(self, user=None):
        """
        Use the new user when constructing success_url.
        """
        return super(RegistrationView, self).get_success_url()
    

    Thus it seems that only two parameters will be passed to that funciton. Yet in your subclass of if you have

    def get_success_url(self, request, user):
       # the named URL that we want to redirect to after # successful    registration
        return ('home') 
    

    Which has an extra request parameter which you are not going to recieve. hence the error.

    0 讨论(0)
  • 2021-01-28 06:54

    The get_success_url method does not take request as an argument. Remove it.

    class MyRegistrationView(RegistrationView):
        def get_success_url(self, user):
            # the named URL that we want to redirect to after # successful registration
            return ('home') 
    

    In this case, since you always redirect to the home view, you could set success_url instead:

    class MyRegistrationView(RegistrationView):
        success_url = 'home'
    
    0 讨论(0)
  • 2021-01-28 06:55

    after version 1.4 the get_success_url method does not take request as an argument:

    def get_success_url(self, user=None):
    

    However, if you do need to process the request object (for example you want to remember the page from which the user decided to register which may be passed as a get or post argument) django-registration-redux provides a very convenient signal: registration.signals.user_registered

    as follows:

    def remember_program_for_registration(sender, user, request, **kwargs):
        [do some processing of the request object]
    
    0 讨论(0)
提交回复
热议问题