File tree Expand file tree Collapse file tree 2 files changed +35
-5
lines changed Expand file tree Collapse file tree 2 files changed +35
-5
lines changed Original file line number Diff line number Diff line change @@ -45,17 +45,32 @@ Add to `settings.py`:
45
45
AUTO_LOGOUT = {' IDLE_TIME' : 600 } # logout after 10 minutes of downtime
46
46
```
47
47
48
+ or the same, but with ` datetime.timedelta ` (more semantically):
49
+
50
+ ``` python
51
+ from datetime import timedelta
52
+
53
+ AUTO_LOGOUT = {' IDLE_TIME' : timedelta(minutes = 10 )}
54
+ ```
55
+
48
56
## ⌛ Limit session time
49
57
50
58
Logout a user after 3600 seconds (hour) from the last login.
51
59
52
60
Add to ` settings.py ` :
53
61
54
-
55
62
``` python
56
63
AUTO_LOGOUT = {' SESSION_TIME' : 3600 }
57
64
```
58
65
66
+ or the same, but with ` datetime.timedelta ` (more semantically):
67
+
68
+ ``` python
69
+ from datetime import timedelta
70
+
71
+ AUTO_LOGOUT = {' SESSION_TIME' : timedelta(hours = 1 )}
72
+ ```
73
+
59
74
## ✉️ Show messages when logging out automatically
60
75
61
76
Set the message that will be displayed after the user automatically logs out of the system:
@@ -95,9 +110,11 @@ in case of downtime (5 minutes or more) and not allow working within one session
95
110
for more than half an hour:
96
111
97
112
``` python
113
+ from datetime import timedelta
114
+
98
115
AUTO_LOGOUT = {
99
- ' IDLE_TIME' : 300 , # 5 minutes
100
- ' SESSION_TIME' : 1800 , # 30 minutes
116
+ ' IDLE_TIME' : timedelta( minutes = 5 ),
117
+ ' SESSION_TIME' : timedelta( minutes = 30 ),
101
118
' MESSAGE' : ' The session has expired. Please login again to continue.' ,
102
119
}
103
120
```
Original file line number Diff line number Diff line change @@ -44,6 +44,11 @@ Add to `settings`:
44
44
45
45
AUTO_LOGOUT = {' IDLE_TIME' : 600 } # logout after 10 minutes of downtime
46
46
47
+ or the same, but with `datetime.timedelta ` (more semantically):
48
+
49
+ .. code :: python
50
+
51
+ AUTO_LOGOUT = {' IDLE_TIME' : timedelta(minutes = 10 )}
47
52
48
53
Limit session time
49
54
------------------
@@ -56,6 +61,12 @@ Add to `settings`:
56
61
57
62
AUTO_LOGOUT = {' SESSION_TIME' : 3600 }
58
63
64
+ or the same, but with `datetime.timedelta ` (more semantically):
65
+
66
+ .. code :: python
67
+
68
+ AUTO_LOGOUT = {' SESSION_TIME' : timedelta(hours = 1 )}
69
+
59
70
Show messages when logging out automatically
60
71
--------------------------------------------
61
72
@@ -95,8 +106,10 @@ for more than half an hour:
95
106
96
107
.. code :: python
97
108
109
+ from datetime import timedelta
110
+
98
111
AUTO_LOGOUT = {
99
- ' IDLE_TIME' : 300 , # 5 minutes
100
- ' SESSION_TIME' : 1800 , # 30 minutes
112
+ ' IDLE_TIME' : timedelta( minutes = 5 ),
113
+ ' SESSION_TIME' : timedelta( minutes = 30 ),
101
114
' MESSAGE' : ' The session has expired. Please login again to continue.' ,
102
115
}
You can’t perform that action at this time.
0 commit comments