search form works
This commit is contained in:
parent
f43c506538
commit
ca066e7c16
|
@ -3,5 +3,5 @@ from django.urls import path
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", views.IndexView.as_view(), name="index"),
|
path("", views.IndexView.as_view(), name="BlogIndex"),
|
||||||
]
|
]
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
from django import forms
|
||||||
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
|
class MainSearchForm(forms.Form):
|
||||||
|
search = forms.CharField(
|
||||||
|
max_length=100,
|
||||||
|
label=''
|
||||||
|
)
|
||||||
|
search.widget = forms.TextInput(
|
||||||
|
attrs={
|
||||||
|
'class': "form-control me-2",
|
||||||
|
'type': "search",
|
||||||
|
'aria-label': "Search",
|
||||||
|
'placeholder': _("Search")
|
||||||
|
}
|
||||||
|
)
|
|
@ -0,0 +1 @@
|
||||||
|
400 you fucked up
|
|
@ -11,7 +11,7 @@
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" href="#">
|
<a class="navbar-brand" href="{% url 'StartIndex' %}">
|
||||||
<img src="https://static.cscherr.de/images/profile/profile-margin.png" alt="Logo" height="30" class="d-inline-block align-text-top">
|
<img src="https://static.cscherr.de/images/profile/profile-margin.png" alt="Logo" height="30" class="d-inline-block align-text-top">
|
||||||
{% translate "cscherr.de" noop %}
|
{% translate "cscherr.de" noop %}
|
||||||
</a>
|
</a>
|
||||||
|
@ -21,10 +21,10 @@
|
||||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" aria-current="page" href="/">{% translate "Start" %}</a>
|
<a class="nav-link active" aria-current="page" href="{% url 'StartIndex' %}">{% translate "Start" %}</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="/blog">{% translate "Blog" %}</a>
|
<a class="nav-link" href="{% url 'BlogIndex' %}">{% translate "Blog" %}</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
|
@ -38,10 +38,12 @@
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<form class="d-flex" role="search">
|
{% block MainSearchFormSpace %}
|
||||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
<form class="d-flex" role="search" action="{% url 'StartMainSearch' %}" method="GET">
|
||||||
|
{{ MainSearchForm }}
|
||||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
<button class="btn btn-outline-success" type="submit">Search</button>
|
||||||
</form>
|
</form>
|
||||||
|
{% endblock MainSearchFormSpace %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -49,29 +51,27 @@
|
||||||
{% block main %}{% endblock main %}
|
{% block main %}{% endblock main %}
|
||||||
</main>
|
</main>
|
||||||
<footer class="text-center text-lg-start bg-white text-muted">
|
<footer class="text-center text-lg-start bg-white text-muted">
|
||||||
<section class="d-flex justify-content-center justify-content-lg-between p-4 border-bottom">
|
<div class="container overflow-hidden text-center">
|
||||||
<div>
|
<div class="row gy-5">
|
||||||
<a href="" class="me-4 link-secondary">
|
<div class="col-6">
|
||||||
<i class="fab fa-facebook-f"></i>
|
<div class="p-3"></div>
|
||||||
</a>
|
</div>
|
||||||
<a href="" class="me-4 link-secondary">
|
<div class="col-6">
|
||||||
<i class="fab fa-twitter"></i>
|
<div class="p-3"></div>
|
||||||
</a>
|
</div>
|
||||||
<a href="" class="me-4 link-secondary">
|
</div>
|
||||||
<i class="fab fa-google"></i>
|
</div>
|
||||||
</a>
|
<section class="bg-secondary-subtle">
|
||||||
<a href="" class="me-4 link-secondary">
|
<div class="container overflow-hidden text-center">
|
||||||
<i class="fab fa-instagram"></i>
|
<div class="row gy-5">
|
||||||
</a>
|
<div class="col-6">
|
||||||
<a href="" class="me-4 link-secondary">
|
<div class="p-3"></div>
|
||||||
<i class="fab fa-linkedin"></i>
|
</div>
|
||||||
</a>
|
<div class="col-6">
|
||||||
<a href="" class="me-4 link-secondary">
|
<div class="p-3"></div>
|
||||||
<i class="fab fa-github"></i>
|
</div>
|
||||||
</a>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
|
||||||
<section class="">
|
|
||||||
<div class="container text-center text-md-start mt-5">
|
<div class="container text-center text-md-start mt-5">
|
||||||
<div class="row mt-3">
|
<div class="row mt-3">
|
||||||
<div class="col-md-3 col-lg-4 col-xl-3 mx-auto mb-4">
|
<div class="col-md-3 col-lg-4 col-xl-3 mx-auto mb-4">
|
||||||
|
|
|
@ -4,10 +4,34 @@
|
||||||
{% block languagecode %}{{ LANGUAGE_CODE }}{% endblock languagecode %}
|
{% block languagecode %}{{ LANGUAGE_CODE }}{% endblock languagecode %}
|
||||||
{% block title %}{% translate "cscherr.de" %} - {% translate "startpage" %}{% endblock title %}
|
{% block title %}{% translate "cscherr.de" %} - {% translate "startpage" %}{% endblock title %}
|
||||||
{% block main %}
|
{% block main %}
|
||||||
<div class="jumbotron text-center">
|
<div class="container-xxl">
|
||||||
|
<div class="jumbotron text-center">
|
||||||
<h1>My First Bootstrap Page</h1>
|
<h1>My First Bootstrap Page</h1>
|
||||||
<p>Resize this responsive page to see the effect!</p>
|
<p>Resize this responsive page to see the effect!</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="container-fluid">
|
<div class="row text-center">
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row text-center">
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row text-center">
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock main %}
|
{% endblock main %}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
{% extends 'start/base.html' %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
|
{% block languagecode %}{{ LANGUAGE_CODE }}{% endblock languagecode %}
|
||||||
|
{% block title %}{% translate "cscherr.de" %} - {% translate "startpage" %}{% endblock title %}
|
||||||
|
{% block main %}
|
||||||
|
<div class="container-xxl">
|
||||||
|
<div class="jumbotron text-center">
|
||||||
|
<h1>{% translate "Search for: " %}</h1>
|
||||||
|
</div>
|
||||||
|
<div class="row text-center">
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row text-center">
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row text-center">
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock main %}
|
|
@ -0,0 +1,36 @@
|
||||||
|
{% extends 'start/base.html' %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
|
{% block languagecode %}{{ LANGUAGE_CODE }}{% endblock languagecode %}
|
||||||
|
{% block title %}{% translate "cscherr.de" %} - {% translate "startpage" %}{% endblock title %}
|
||||||
|
{% block main %}
|
||||||
|
<div class="container-xxl">
|
||||||
|
<div class="jumbotron text-center">
|
||||||
|
<h1>{% translate "Search for:" %} {{ searchstr }}</h1>
|
||||||
|
</div>
|
||||||
|
<div class="row text-center">
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row text-center">
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row text-center">
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
Column
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock main %}
|
|
@ -3,5 +3,7 @@ from django.urls import path
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", views.IndexView.as_view(), name="index"),
|
path("", views.IndexView.as_view(), name="StartIndex"),
|
||||||
|
path("search/", views.MainSearchView.as_view(), name="StartMainSearch"),
|
||||||
|
path("legal/", views.LegalInfoView.as_view(), name="StartLegalInfo"),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
from django.http import HttpResponse
|
from http.client import HTTPResponse
|
||||||
from django.views.generic.base import TemplateView
|
from django.apps import AppConfig
|
||||||
|
from django.http import Http404, HttpResponse, HttpResponseBadRequest, response
|
||||||
|
from django.urls import Resolver404
|
||||||
|
from django.views.generic import TemplateView, ListView
|
||||||
from django.views import View
|
from django.views import View
|
||||||
from django.template import Template, loader
|
from django.template import Template, context, loader
|
||||||
|
from django.http import HttpResponseRedirect
|
||||||
|
from django.shortcuts import render
|
||||||
|
from .forms import MainSearchForm
|
||||||
|
|
||||||
class IndexView(TemplateView):
|
class IndexView(TemplateView):
|
||||||
"""
|
"""
|
||||||
|
@ -14,3 +19,36 @@ class IndexView(TemplateView):
|
||||||
|
|
||||||
template_name: str = "start/index.html"
|
template_name: str = "start/index.html"
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context["MainSearchForm"] = MainSearchForm()
|
||||||
|
return context
|
||||||
|
|
||||||
|
class LegalInfoView(TemplateView):
|
||||||
|
"""
|
||||||
|
Legal info that the german authorities want.
|
||||||
|
"""
|
||||||
|
|
||||||
|
template_name: str = "start/legalinfo.html"
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context["MainSearchForm"] = MainSearchForm()
|
||||||
|
return context
|
||||||
|
|
||||||
|
class MainSearchView(TemplateView):
|
||||||
|
"""
|
||||||
|
Search for anything.
|
||||||
|
"""
|
||||||
|
|
||||||
|
template_name: str = "start/search.html"
|
||||||
|
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
form = MainSearchForm(request.GET)
|
||||||
|
if not form.is_valid():
|
||||||
|
return render(request, "errors/bad_request.html")
|
||||||
|
context = {
|
||||||
|
"searchstr": form.cleaned_data['search'],
|
||||||
|
"MainSearchForm": MainSearchForm()
|
||||||
|
}
|
||||||
|
return render(request=request, template_name=self.template_name, context=context)
|
||||||
|
|
Loading…
Reference in New Issue