Plain is headed towards 1.0! Subscribe for development updates →

 1# plain.password
 2
 3Password authentication for Plain.
 4
 5## Usage
 6
 7To enable password authentication in your Plain application, add the `PasswordLoginView` to your `urls.py`:
 8
 9```python
10# app/urls.py
11from plain.urls import path
12from plain.passwords.views import PasswordLoginView
13
14urlpatterns = [
15    path('login/', PasswordLoginView, name='login'),
16    # ...
17]
18```
19
20This sets up a basic login view where users can authenticate using their username and password.
21
22For password resets to work, you also need to install [plain.email](/plain-email/README.md).
23
24## FAQs
25
26### How do I customize the login form?
27
28To customize the login form, you can subclass `PasswordLoginForm` and override its fields or methods as needed. Then, set the `form_class` attribute in your `PasswordLoginView` to use your custom form.
29
30```python
31# app/forms.py
32from plain.passwords.forms import PasswordLoginForm
33
34class MyCustomLoginForm(PasswordLoginForm):
35    # Add custom fields or override methods here
36    pass
37```
38
39```python
40# app/views.py
41from plain.passwords.views import PasswordLoginView
42from .forms import MyCustomLoginForm
43
44class MyPasswordLoginView(PasswordLoginView):
45    form_class = MyCustomLoginForm
46```
47
48Update your `urls.py` to use your custom view:
49
50```python
51# app/urls.py
52from plain.urls import path
53from .views import MyPasswordLoginView
54
55urlpatterns = [
56    path('login/', MyPasswordLoginView, name='login'),
57    # ...
58]
59```