Reputation: 75
I have been working in django CBV but i am stuck and cannot reslove it i also googled that thing but nothing much i get it sometimes in classes we use super
class ArticleCounterRedirectView(RedirectView):
permanent = False
query_string = True
pattern_name = 'article-detail'
def get_redirect_url(self, *args, **kwargs):
article = get_object_or_404(Article, pk=kwargs['pk'])
article.update_counter()
return super().get_redirect_url(*args, **kwargs)
class ArticleCounterRedirectView(RedirectView):
permanent = False
query_string = True
pattern_name = 'article-detail'
def get_redirect_url(self, *args, **kwargs):
article = get_object_or_404(Article, pk=kwargs['pk'])
article.update_counter()
return super(ArticleCounterRedirectView,self).get_redirect_url(*args, **kwargs)
we use super to to call the parent class then in one example we give no arguments and in another we give it two arguements please can someone help me out in this
Upvotes: 0
Views: 88
Reputation: 1610
super().get_redirect_url(*args, **kwargs)
And
super(ArticleCounterRedirectView,self).get_redirect_url(*args, **kwargs)
Both do the same thing in this case essentially,
The first one is the new syntax in python 3. If you want to explicitly bypass the MRO then you can use the second method to do that.
Hope you understood.
Upvotes: 1