Changed HTMX templates

This commit is contained in:
ferdzo
2023-04-18 14:29:16 +02:00
parent d25861e44a
commit d2c7990ee9
4 changed files with 36 additions and 30 deletions

View File

@@ -1,13 +1,17 @@
from django import forms
from .models import Insert
class DateInput(forms.DateInput):
input_type = 'date'
class InputForm(forms.ModelForm):
class Meta:
model = Insert
fields = {"name", "phone", "description", "date","done"}
labels = {'name': "Name", 'phone': "Phone", 'date': "Date", 'description': "Description",'done':"Done"}
labels = {'name': "Name", 'phone': "Phone", 'date': "Date", 'description': "Description",'done':"Done"}
widgets = {
'date': DateInput(),
}
field_order =["name", "phone", "description", "date","done"]
# name = forms.CharField(label="Name", max_length=30)

View File

@@ -40,8 +40,11 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'crispy_forms'
'crispy_forms',
'crispy_bootstrap5'
]
CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
CRISPY_TEMPLATE_PACK = "bootstrap5"
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',

View File

@@ -0,0 +1,21 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<title>Service </title>
</head>
<body>
<div class="container">
<div class="row justify-content-center">
<div class="col-8">
<h1 class="mt-2">Django People</h1>
<hr class="mt-0 mb-4">
{% block content %}
{% endblock %}
</div>
</div>
</div>
</body>
</html>

View File

@@ -1,31 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
{% extends 'base.html' %}
{% block content %}
{% csrf_token %}
<form action="/insert/" method="post">
{% comment %} <label for="name">Name</label></br>
<input type="text" name="name" id="name"></br>
<label for="phone">Phone</label></br>
<input type="text" name="phone" id="phone"></br>
<label for="date">Date</label></br>
<input type="date" name="date" id="date"></br>
<label for="Description">Description</label></br>
<input type="text" name="Description" id="Description"></br>
<br>
<input type="submit" value="OK"> {% endcomment %}
{% csrf_token %}
{{form.as_p}}
<input type="submit" value="Submit">
<input type="submit" class="btn btn-success" value="Submit">
</form>
</body>
</html>
{% endblock%}