'how to make the captcha have a bootstrap class?
I have a problem with the captcha, I'm using the ¨Django Simple Captcha¨ the problem is that it doesn't let me place a bootstrap class so that the input has a better appearance.
I tried to:
- I Put widget_tweaks in that input, but it does not send the data correctly and marks errors
html
<label class="form-label">Captcha</label>
{% render_field form.captcha class="form-control" %}
- From forms I placed a class inside the widget, but it doesn't work
forms.py
class RegisterForm(UserCreationForm):
captcha=CaptchaField(widget=forms.TextInput(attrs={'class': 'form-control'}))
- I took the input id and edit it in my style.css but the bootstrap class is not visible either
style.css
#id_captcha_1{
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.42857143;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
}
Any ideas for that input to have the bootstrap class?
Solution 1:[1]
Two solutions.
The first uses a group by:
select * from Table1 where
("Id", "TypeEmployment") in
(select
"Id", min("TypeEmployment")
from Table1
group by "Id")
order by 5, 2 desc, 4, 3 desc
;
The second uses a window function min:
WITH subq as (select
*, min("TypeEmployment") over (partition by "Id") mini
from Table1)
select
"Id",
"EmployeePositionId",
"Date",
"Time",
"TypeEmployment"
from
subq
where
"TypeEmployment"="mini"
order by 5, 2 desc, 4, 3 desc
;
DDL:
CREATE TABLE Table1
("Id" int, "EmployeePositionId" int, "Date" timestamp, "Time" int, "TypeEmployment" int)
;
INSERT INTO Table1
("Id", "EmployeePositionId", "Date", "Time", "TypeEmployment")
VALUES
(4399, 4557, '2022-01-10 00:00:00', 60, 0),
(4399, 4557, '2022-01-10 00:00:00', 480, 0),
(4399, 4561, '2022-01-10 00:00:00', 540, 1),
(4399, 4559, '2022-01-10 00:00:00', 540, 2),
(2448, 3017, '2022-01-31 00:00:00', 480, 0),
(2448, 3017, '2022-01-28 00:00:00', 480, 0),
(3406, 3841, '2022-01-31 00:00:00', 480, 1),
(3406, 3841, '2022-01-28 00:00:00', 480, 1),
(3406, 3841, '2022-01-27 00:00:00', 480, 1),
(3406, 3841, '2022-01-26 00:00:00', 480, 1)
;
Output:
| Id | EmployeePositionId | Date | Time | TypeEmployment |
|---|---|---|---|---|
| 4399 | 4557 | 2022-01-10T00:00:00Z | 60 | 0 |
| 4399 | 4557 | 2022-01-10T00:00:00Z | 480 | 0 |
| 2448 | 3017 | 2022-01-31T00:00:00Z | 480 | 0 |
| 2448 | 3017 | 2022-01-28T00:00:00Z | 480 | 0 |
| 3406 | 3841 | 2022-01-31T00:00:00Z | 480 | 1 |
| 3406 | 3841 | 2022-01-28T00:00:00Z | 480 | 1 |
| 3406 | 3841 | 2022-01-27T00:00:00Z | 480 | 1 |
| 3406 | 3841 | 2022-01-26T00:00:00Z | 480 | 1 |
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
