mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #23919 -- Replaced super(ClassName, self) with super() in docs.
This commit is contained in:
@@ -131,7 +131,7 @@ MRO is an acronym for Method Resolution Order.
|
||||
template_name = "home.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(HomePageView, self).get_context_data(**kwargs)
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['latest_articles'] = Article.objects.all()[:5]
|
||||
return context
|
||||
|
||||
@@ -194,7 +194,7 @@ MRO is an acronym for Method Resolution Order.
|
||||
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)
|
||||
return super().get_redirect_url(*args, **kwargs)
|
||||
|
||||
**Example urls.py**::
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ many projects they are typically the most commonly used views.
|
||||
model = Article
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ArticleDetailView, self).get_context_data(**kwargs)
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['now'] = timezone.now()
|
||||
return context
|
||||
|
||||
@@ -117,7 +117,7 @@ many projects they are typically the most commonly used views.
|
||||
model = Article
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ArticleListView, self).get_context_data(**kwargs)
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['now'] = timezone.now()
|
||||
return context
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ editing content:
|
||||
# This method is called when valid form data has been POSTed.
|
||||
# It should return an HttpResponse.
|
||||
form.send_email()
|
||||
return super(ContactView, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
**Example myapp/contact.html**:
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ Simple mixins
|
||||
arguments provided will make up the returned context. Example usage::
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(RandomNumberView, self).get_context_data(**kwargs)
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['number'] = random.randrange(1, 100)
|
||||
return context
|
||||
|
||||
|
||||
Reference in New Issue
Block a user