Skip to content

Commit bd0e6e8

Browse files
authored
docs: update comments and import in action-form-example.md (#1565)
1 parent b697510 commit bd0e6e8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/actions/action-form-example.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This example demonstrates how to create an action that displays a custom form wh
1313

1414
from django import forms
1515
from django.contrib.auth.models import User
16-
from django.http import HttpRequest
16+
from django.http import HttpRequest, HttpResponse
1717
from django.shortcuts import render
1818
from django.urls import reverse_lazy
1919
from django.utils.translation import gettext_lazy as _
@@ -24,7 +24,7 @@ from unfold.widgets import UnfoldAdminTextInputWidget, UnfoldAdminSplitDateTimeW
2424

2525

2626
class SomeForm(forms.Form):
27-
# It is important to set a widget coming from Unfold
27+
# It is important to set up a widget from Unfold.
2828
date_start = forms.SplitDateTimeField(label=_("Start"), widget=UnfoldAdminSplitDateTimeWidget)
2929
date_end = forms.SplitDateTimeField(label=_("End"), widget=UnfoldAdminSplitDateTimeWidget)
3030
note = forms.CharField(label=_("Note"), widget=UnfoldAdminTextInputWidget)
@@ -45,8 +45,8 @@ class UserAdmin(ModelAdmin):
4545
actions_detail = ["change_detail_action"]
4646

4747
@action(description=_("Change detail action"), url_path="change-detail-action")
48-
def change_detail_action(self, request: HttpRequest, object_id: int) -> str:
49-
# Check if object already exists, otherwise returs 404
48+
def change_detail_action(self, request: HttpRequest, object_id: int) -> HttpResponse:
49+
# Check whether the object already exists; otherwise, return a 404 error.
5050
obj = get_object_or_404(User, pk=object_id)
5151
form = SomeForm(request.POST or None)
5252

@@ -74,7 +74,7 @@ class UserAdmin(ModelAdmin):
7474
)
7575
```
7676

77-
Template displaying the form. Please note that breadcrumbs are empty in this case but if you want, you can configure your own breadcrumbs path.
77+
This is the template for the form. Please note that the breadcrumbs are empty in this case, but you can configure your own breadcrumb path if you wish.
7878

7979
```html
8080
{% extends "admin/base_site.html" %}

0 commit comments

Comments
 (0)