exibindo dados do banco no html

This commit is contained in:
2024-12-10 20:42:10 -03:00
parent 91dde27384
commit fbb326f347
26 changed files with 170 additions and 24 deletions

View File

@@ -1,5 +1,7 @@
mkdir djangotutorial
python -m venv meu_ambiente
django-admin startproject mysite djangotutorial
meu_ambiente\Scripts\Activate.ps1
python manage.py runserver
python manage.py startapp polls
python manage.py makemigrations

Binary file not shown.

View File

@@ -19,6 +19,7 @@ from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('/', include('home.urls')),
path('products/', include('products.urls')),
path('mesas/', include('mesas.urls')),
path('typePay/', include('typePay.urls')),

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
gestaoRaul/home/admin.py Normal file
View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
gestaoRaul/home/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class HomeConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'home'

View File

View File

@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

View File

@@ -0,0 +1,32 @@
{% extends "base.html" %}
{% load static %}
{% block 'head' %}
<link rel="stylesheet" href="{% static 'mesas/css/mesas.css' %}">
{% endblock %}
{% block 'title' %}
RRB&C - DashBoard
{% endblock %}
{% block 'body' %}
<body>
<div class="grid-container">
<h1>DashBoard Aqui</h1>
{% comment %} {% for mesa in mesas %}
<div class="card">{{mesa.name}}</div>
{% endfor %} {% endcomment %}
</div>
</body>
{% endblock %}

3
gestaoRaul/home/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

7
gestaoRaul/home/urls.py Normal file
View File

@@ -0,0 +1,7 @@
from django.urls import path
from . import views
urlpatterns = [
path('', views.home, name='home'),
]

5
gestaoRaul/home/views.py Normal file
View File

@@ -0,0 +1,5 @@
from django.shortcuts import render
# Create your views here.
def home(request):
return render(request, 'home.html')

View File

@@ -1,3 +1,18 @@
from django.contrib import admin
from categories.models import Categories
from clients.models import Client
from comandas.models import Comanda
from typePay.models import TypePay
from products.models import Product
from mesas.models import Mesa
admin.site.register(Mesa)
admin.site.register(Product)
admin.site.register(Categories)
admin.site.register(Client)
admin.site.register(Comanda)
admin.site.register(TypePay)
# Register your models here.

View File

@@ -18,24 +18,10 @@ RRB&C - Mesas
{% for mesa in mesas %}
<div class="card">Mesa {{mesa}}</div>
<div class="card">{{mesa.name}}</div>
{% endfor %}
{% comment %} <div class="card">Card 2</div>
<div class="card">Card 3</div>
<div class="card">Card 4</div>
<div class="card">Card 5</div>
<div class="card">Card 6</div>
<div class="card">Card 7</div>
<div class="card">Card 8</div>
<div class="card">Card 9</div>
<div class="card">Card 10</div>
<div class="card">Card 8</div>
<div class="card">Card 9</div>
<div class="card">Card 10</div>
<div class="card">Card 8</div>
<div class="card">Card 9</div>
<div class="card">Card 10</div> {% endcomment %}
</div>
</body>

View File

@@ -1,6 +1,9 @@
from django.shortcuts import render
from mesas.models import Mesa
# Create your views here.
def mesas(request):
return render(request, 'mesas.html', {'mesas': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']})
mesas = Mesa.objects.all()
return render(request, 'mesas.html', {'mesas': mesas})

View File

@@ -1,12 +1,33 @@
{% extends "base.html" %}
{% load static %}
{% block 'head' %}
<link rel="stylesheet" href="{% static 'mesas/css/mesas.css' %}">
{% endblock %}
{% block 'title' %}
Type Pay
Produtos
{% endblock %}
{% block 'body' %}
Body Type Pay
<body>
<div class="grid-container">
{% for product in products %}
<div class="card">{{product.name}}</div>
{% endfor %}
</div>
</body>
{% endblock %}

View File

@@ -1,5 +1,8 @@
from django.shortcuts import render
from products.models import Product
def products(request):
return render(request, 'products.html')
protucts = Product.objects.all()
return render(request, 'products.html', {'products': protucts})

View File

@@ -1,15 +1,36 @@
{% load static %}
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{% static 'base.css' %}">
{% block 'head' %}{% endblock %}
<title> {% block 'title' %}{% endblock %} </title>
</head>
<div>aqui o menu</div>
<div>
aqui o menu
<div class="sidebar">
<ul>
<li><a href="#">Home</a></li>
<li><a href="{% url 'mesas' %}">Mesas</a></li>
<li><a href="#">Comandas</a></li>
<li><a href="{% url 'products' %}">Produtos</a></li>
<li><a href="#">Categorias</a></li>
<li><a href="#">Sobre</a></li>
</ul>
</div>
<div class="content">
<h1>Bem-vindo ao meu site!</h1>
</div>
</div>
<body>
{% block 'body' %}
{% endblock %}

View File

@@ -0,0 +1,35 @@
body {
margin: 0;
font-family: Arial, sans-serif;
}
.sidebar {
height: 100vh;
width: 200px;
background-color: #f1f1f1;
padding: 20px;
position: fixed;
top: 0;
left: 0;
}
.content {
margin-left: 220px; /* Ajustar para a largura da sidebar + padding */
padding: 20px;
}
ul {
list-style-type: none;
padding: 0;
}
li a {
display: block;
padding: 15px;
text-decoration: none;
color: #333;
}
li a:hover {
background-color: #ccc;
}