Форум программистов, компьютерный форум, киберфорум
Python: Django
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.63/8: Рейтинг темы: голосов - 8, средняя оценка - 4.63
0 / 0 / 0
Регистрация: 08.10.2021
Сообщений: 25

Передать несколько параметров GET

29.11.2022, 13:23. Показов 1695. Ответов 4
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Всем привет. Не могу понять, как через кнопки передать несколько запросов. Проблема в том, что если я нажимаю на кнопку и передаю запрос, то этот запрос заменяет старый, хотя мне нужно, что бы они объединялись. Если я прописываю все руками в строке, то все работает. Т. е. проблема именно в замене старого на новый. Создаю сайт на Django.
Я не знаю куда задавать такой вопрос: в тему Django или сюда, поэтому сначала написал сюда.
Также я не понимаю, как передавать (ну и объединять) параметры при нажатии на чекбокс. Думаю тут мне нужен JavaScript. Я только учусь, поэтому сори за сумбурность и вопросы, скорее всего, не по теме.

HTML5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
{% load menu %}
 
<!-- Shop Sidebar Start -->
<div class="col-lg-3 col-md-4">
    <!-- Price Start -->
    <h5 class="section-title position-relative text-uppercase mb-3">
        <span class="bg-secondary pr-3">
            Цена
        </span>
    </h5>
    <div class="bg-light p-4 mb-30">
        <form method="get">
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" checked id="price-all">
                <label class="custom-control-label" for="price-all">Все</label>
            </div>
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" id="price-1" value="0-100">
                <label class="custom-control-label" for="price-1">0 - 100 ₽</label>
            </div>
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" id="price-2">
                <label class="custom-control-label" for="price-2">100 - 200 ₽</label>
            </div>
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" id="price-3">
                <label class="custom-control-label" for="price-3">200 - 300 ₽</label>
            </div>
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" id="price-4">
                <label class="custom-control-label" for="price-4">300 - 400 ₽</label>
            </div>
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" id="price-5">
                <label class="custom-control-label" for="price-5">400 - 500 ₽</label>
            </div>
        </form>
    </div>
    <!-- Price End -->
 
    <!-- Color Start -->
    <h5 class="section-title position-relative text-uppercase mb-3">
        <span class="bg-secondary pr-3">
            Цвет
        </span>
    </h5>
    <div class="bg-light p-4 mb-30">
        <form>
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" checked id="color-all">
                <label class="custom-control-label" for="price-all">Все</label>
            </div>
            
            {% show_color as colors %}
 
            {% for c in colors %}
            {% if c.product__count > 0 %}
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" id="color-{{ forloop.counter }}">
                <label class="custom-control-label" for="color-{{ forloop.counter }}">{{ c.color }}</label>
            </div>
            {% endif %}
            {% endfor %}
        </form>
    </div>
    <!-- Color End -->
 
    <!-- Size Start -->
    <h5 class="section-title position-relative text-uppercase mb-3">
        <span class="bg-secondary pr-3">
            Размер
        </span>
    </h5>
    <div class="bg-light p-4 mb-30">
        <form>
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" checked id="size-all">
                <label class="custom-control-label" for="size-all">Все</label>
            </div>
 
            {% show_size as size %}
 
            {% for s in size %}
            {% if s.product__count > 0 %}
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" id="size-{{ forloop.counter }}">
                <label class="custom-control-label" for="size-{{ forloop.counter }}">{{ s.size }}</label>
            </div>
            {% endif %}
            {% endfor %}
        </form>
    </div>
    <!-- Size End -->
 
    <!-- Brand Start -->
    <h5 class="section-title position-relative text-uppercase mb-3">
        <span class="bg-secondary pr-3">
            Бренд
        </span>
    </h5>
    <div class="bg-light p-4 mb-30">
        <form method="get">
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" checked id="price-all">
                <label class="custom-control-label" for="price-all">Все</label>
            </div>
 
            {% show_brand as brand %}
 
            {% for b in brand %}
            {% if b.product__count > 0 %}
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" id="price-{{ forloop.counter }}">
                <label class="custom-control-label" for="price-{{ forloop.counter }}">{{ b.brand }}</label>
            </div>
            {% endif %}
            {% endfor %}
        </form>
    </div>
    <!-- Brand End -->
</div>
<!-- Shop Sidebar End -->
0
cpp_developer
Эксперт
20123 / 5690 / 1417
Регистрация: 09.04.2010
Сообщений: 22,546
Блог
29.11.2022, 13:23
Ответы с готовыми решениями:

Передать несколько параметров
здравствуйте при создании меню в классе при нажатии на ПКМ нужно передать несколько параметров, можно ли? как? пробовал, не...

Передать в поток несколько параметров
Thread thread2 = new Thread(new ParameterizedThreadStart(_goalworker.Goals)); thread2.Start(Param1); помогите как правильно...

Как передать несколько параметров в функцию
Как передать несколько параметров в функцию? пытаюсь передать переменную s она объявлена глобально но бъет ошибку function...

4
Просто Лис
Эксперт Python
 Аватар для Рыжий Лис
5972 / 3734 / 1099
Регистрация: 17.05.2012
Сообщений: 10,791
Записей в блоге: 9
30.11.2022, 18:15
Лучший ответ Сообщение было отмечено ManeChelMain как решение

Решение

Ты же, вроде, писал, что get-параметры менять нельзя (или их только поисковик проидексировал?).

Форму одну сделай, а не несколько.
0
0 / 0 / 0
Регистрация: 08.10.2021
Сообщений: 25
01.12.2022, 14:47  [ТС]
Рыжий Лис, я сделал все в одной форме. Работает, но если выбираешь несколько значений одного запроса, то форма считает это за 2 запроса, хотя должна считать за 1 запрос. Например вместо ?color=chernyj,krasnyj пишет ?color=chernyj&color=krasnyj. Таким образом он работает по последнему запросу, т.е. выбирает только красный цвет. В варианте ?color=chernyj,krasnyj работает как надо, опять же.

HTML5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
{% load menu %}
 
<!-- Shop Sidebar Start -->
<div class="col-lg-3 col-md-4">
    <form method="get">
        <!-- Price Start -->
        <h5 class="section-title position-relative text-uppercase mb-3">
            <span class="bg-secondary pr-3">
                Цена
            </span>
        </h5>
        <div class="bg-light p-4 mb-30">
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" id="price-1" name="price" value="0-100">
                <label class="custom-control-label" for="price-1">0 - 100 ₽</label>
            </div>
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" id="price-2" name="price" value="101-200">
                <label class="custom-control-label" for="price-2">101 - 200 ₽</label>
            </div>
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" id="price-3" name="price" value="201-300">
                <label class="custom-control-label" for="price-3">201 - 300 ₽</label>
            </div>
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" id="price-4" name="price" value="301-400">
                <label class="custom-control-label" for="price-4">301 - 400 ₽</label>
            </div>
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" id="price-5" name="price" value="401-500">
                <label class="custom-control-label" for="price-5">401 - 500 ₽</label>
            </div>
        </div>
        <!-- Price End -->
 
        <!-- Color Start -->
        <h5 class="section-title position-relative text-uppercase mb-3">
            <span class="bg-secondary pr-3">
                Цвет
            </span>
        </h5>
        <div class="bg-light p-4 mb-30">
            {% show_color as colors %}
 
            {% for c in colors %}
            {% if c.product__count > 0 %}
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" id="color-{{ forloop.counter }}" name="color"
                    value="{{ c.slug }}">
                <label class="custom-control-label" for="color-{{ forloop.counter }}">{{ c.color }}</label>
            </div>
            {% endif %}
            {% endfor %}
        </div>
        <!-- Color End -->
 
        <!-- Size Start -->
        <h5 class="section-title position-relative text-uppercase mb-3">
            <span class="bg-secondary pr-3">
                Размер
            </span>
        </h5>
        <div class="bg-light p-4 mb-30">
            {% show_size as size %}
 
            {% for s in size %}
            {% if s.product__count > 0 %}
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" id="size-{{ forloop.counter }}" name="size"
                    value="{{ s.slug }}">
                <label class="custom-control-label" for="size-{{ forloop.counter }}">{{ s.size }}</label>
            </div>
            {% endif %}
            {% endfor %}
        </div>
        <!-- Size End -->
 
        <!-- Brand Start -->
        <h5 class="section-title position-relative text-uppercase mb-3">
            <span class="bg-secondary pr-3">
                Бренд
            </span>
        </h5>
        <div class="bg-light p-4 mb-30">
            {% show_brand as brand %}
 
            {% for b in brand %}
            {% if b.product__count > 0 %}
            <div class="custom-control custom-checkbox d-flex align-items-center justify-content-between mb-3">
                <input type="checkbox" class="custom-control-input" id="brand-{{ forloop.counter }}" name="brand"
                    value="{{ b.slug }}">
                <label class="custom-control-label" for="brand-{{ forloop.counter }}">{{ b.brand }}</label>
            </div>
            {% endif %}
            {% endfor %}
        </div>
        <!-- Brand End -->
        <button type="submit">Применить</button>
    </form>
</div>
<!-- Shop Sidebar End -->
0
Просто Лис
Эксперт Python
 Аватар для Рыжий Лис
5972 / 3734 / 1099
Регистрация: 17.05.2012
Сообщений: 10,791
Записей в блоге: 9
03.12.2022, 10:02
Лучший ответ Сообщение было отмечено ManeChelMain как решение

Решение

Цитата Сообщение от ManeChelMain Посмотреть сообщение
Например вместо ?color=chernyj,krasnyj пишет ?color=chernyj&color=krasnyj
Ну да, так работают браузеры.
Цитата Сообщение от ManeChelMain Посмотреть сообщение
пишет ?color=chernyj&color=krasnyj.
Python
1
print(request.GET.getlist('color'))
0
0 / 0 / 0
Регистрация: 08.10.2021
Сообщений: 25
03.12.2022, 10:19  [ТС]
Рыжий Лис, я беру за пример сайт DNS. Когда я выбираю несколько цен, то в строке появляется это ?price=16001-31000,31001-49000. Вот я и подумал, что можно также сделать и у меня. Это я просто для примера написал.
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
raxper
Эксперт
30234 / 6612 / 1498
Регистрация: 28.12.2010
Сообщений: 21,154
Блог
03.12.2022, 10:19
Помогаю со студенческими работами здесь

Как передать несколько параметров с формы?
Здравствуйте. Столкнулся со следующей проблемой. На странице выведены несколько div-ов с картинками, ссылками и описанием к картинкам. ...

Как в ShellExecute передать несколько параметров?
Допустим такой вызов ShellExecuteA(NULL, &quot;open&quot;, &quot;cmd.exe&quot;, &quot;/C ipconfig&quot; , NULL, SW_SHOW); А как затем передать &quot; /C pause&quot;...

Как передать несколько параметров в поток?
не актуально

Как передать несколько параметров из ASP в dll
Форма запускает asp скрипт , который в свою очередь запускает dll. Мне надо передать dll несколько параметров методом POST.

Передать функции массив как несколько параметров
Как передать функции массив как несколько параметров те где каждый элемент будет выступать как отдельный параметр


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
5
Ответ Создать тему
Новые блоги и статьи
http://iceja.net/ математические сервисы
iceja 20.01.2026
Обновила свой сайт http:/ / iceja. net/ , приделала Fast Fourier Transform экстраполяцию сигналов. Однако предсказывает далеко не каждый сигнал (см ограничения http:/ / iceja. net/ fourier/ docs ). Также. . .
http://iceja.net/ сервер решения полиномов
iceja 18.01.2026
Выкатила http:/ / iceja. net/ сервер решения полиномов (находит действительные корни полиномов методом Штурма). На сайте документация по API, но скажу прямо VPS слабенький и 200 000 полиномов. . .
Расчёт переходных процессов в цепи постоянного тока
igorrr37 16.01.2026
/ * Дана цепь постоянного тока с R, L, C, k(ключ), U, E, J. Программа составляет систему уравнений по 1 и 2 законам Кирхгофа, решает её и находит переходные токи и напряжения на элементах схемы. . . .
Восстановить юзерскрипты Greasemonkey из бэкапа браузера
damix 15.01.2026
Если восстановить из бэкапа профиль Firefox после переустановки винды, то список юзерскриптов в Greasemonkey будет пустым. Но восстановить их можно так. Для этого понадобится консольная утилита. . .
Сукцессия микоризы: основная теория в виде двух уравнений.
anaschu 11.01.2026
https:/ / rutube. ru/ video/ 7a537f578d808e67a3c6fd818a44a5c4/
WordPad для Windows 11
Jel 10.01.2026
WordPad для Windows 11 — это приложение, которое восстанавливает классический текстовый редактор WordPad в операционной системе Windows 11. После того как Microsoft исключила WordPad из. . .
Classic Notepad for Windows 11
Jel 10.01.2026
Old Classic Notepad for Windows 11 Приложение для Windows 11, позволяющее пользователям вернуть классическую версию текстового редактора «Блокнот» из Windows 10. Программа предоставляет более. . .
Почему дизайн решает?
Neotwalker 09.01.2026
В современном мире, где конкуренция за внимание потребителя достигла пика, дизайн становится мощным инструментом для успеха бренда. Это не просто красивый внешний вид продукта или сайта — это. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru