@register.filter
def get_active_portfolio_items(client):
return Portfolio.objects.filter(client=client, active=True)
{% for port in i|get_active_portfolio_items%}
{{ port}}
{% endfor %}
function add_to_cart(id) {
let token = '{{csrf_token}}';
$.ajax({
headers: { "X-CSRFToken": token },
url: '/add-to-cart/',
type: 'POST',
data: {'id':id},
success: function(data) {
get_cart()
},
failure: function(data) {
console.log('Не успешно');
}
});
}
for line in range(1,10):
for place in range(1,50):
print(f'Билет на {line}-й ряд, {place}-е место')
#models.py
#Django Models ChoiceField
class Profile(models.Model):
# Country Choices
CHOICES = (
('US', 'United States'),
('FR', 'France'),
('CN', 'China'),
('RU', 'Russia'),
('IT', 'Italy'),
)
username = models.CharField(max_length=300)
country = models.CharField(max_length=300, choices = CHOICES)
def __str__(self):
return self.username
<!DOCTYPE html>
<html>
<head>
<title>Meter</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
</head>
<body>
<form method="POST" id="myForm">
<input name="q1" value="1231" id="value1" type="checkbox" />
<input name="q1" value="false" id="value1" type="checkbox" />
<input name="q1" value="1231" id="value1" type="checkbox" />
<input type="button" name="" id="btn" value="1">
</form>
<script type="text/javascript">
$( document ).ready(function() {
$('#myForm').find ('input, textearea, select').each(function() {
let value = $(this).val()//Получаем значение инпута
if (value == 1231) {//Вместо цифр подставить сравнение с куки
$(this).prop('checked', true);//Установка элементу свойства checked
}
});
});
</script>
</body>
</html>