Answer the question
In order to leave comments, you need to log in
GET request in Django?
Good evening. I'm doing my little Django project. There is HTML code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Main</title>
</head>
<body>
<div>
<h1>Таблица сайтов</h1>
<table>
<tr>
<th>Название</th>
<th>Описание</th>
</tr>
{% for el in sites %}
<tr>
<td><a {% if el.url != '' %} href="link/", test = "{{el.url}}"
{% else %} onclick="alert('Ошибка. Отсутствует URL.') "LANGUAGE="Javascript" {% endif %}>{{ el.name }}</a></td>
{% if el.description != '' %}
<td>{{ el.description }}</td>
{% else %}
<td>Отсутствует описание</td>
{% endif %}
</tr>
{% endfor %}
</table>
</div>
</body>
</html>
def index(request):
sites = table.objects.all()
return render(request, 'main/index.html', {'sites': sites})
def make_qr_code(url):
s = url.GET.get('test',"")
output = "<h1>Hello, link is {0}</h1>".format(s)
return HttpResponse(output)
from django.urls import path
from django.conf.urls import url
from . import views
urlpatterns = [
path('', views.index),
path('link/', views.make_qr_code, name='qr')
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question