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 mkdir djangotutorial
python -m venv meu_ambiente
django-admin startproject mysite djangotutorial django-admin startproject mysite djangotutorial
meu_ambiente\Scripts\Activate.ps1
python manage.py runserver python manage.py runserver
python manage.py startapp polls python manage.py startapp polls
python manage.py makemigrations python manage.py makemigrations

Binary file not shown.

View File

@@ -19,6 +19,7 @@ from django.urls import path, include
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('/', include('home.urls')),
path('products/', include('products.urls')), path('products/', include('products.urls')),
path('mesas/', include('mesas.urls')), path('mesas/', include('mesas.urls')),
path('typePay/', include('typePay.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 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. # Register your models here.

View File

@@ -18,24 +18,10 @@ RRB&C - Mesas
{% for mesa in mesas %} {% for mesa in mesas %}
<div class="card">Mesa {{mesa}}</div> <div class="card">{{mesa.name}}</div>
{% endfor %} {% 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> </div>
</body> </body>

View File

@@ -1,6 +1,9 @@
from django.shortcuts import render from django.shortcuts import render
from mesas.models import Mesa
# Create your views here. # Create your views here.
def mesas(request): 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" %} {% extends "base.html" %}
{% load static %}
{% block 'head' %}
<link rel="stylesheet" href="{% static 'mesas/css/mesas.css' %}">
{% block 'title' %}
Type Pay
{% endblock %} {% endblock %}
{% block 'title' %}
Produtos
{% endblock %}
{% block 'body' %} {% block 'body' %}
Body Type Pay
<body>
<div class="grid-container">
{% for product in products %}
<div class="card">{{product.name}}</div>
{% endfor %}
</div>
</body>
{% endblock %} {% endblock %}

View File

@@ -1,5 +1,8 @@
from django.shortcuts import render from django.shortcuts import render
from products.models import Product
def products(request): 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 %} {% load static %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="pt-BR"> <html lang="pt-BR">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{% static 'base.css' %}">
{% block 'head' %}{% endblock %} {% block 'head' %}{% endblock %}
<title> {% block 'title' %}{% endblock %} </title> <title> {% block 'title' %}{% endblock %} </title>
</head> </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> <body>
{% block 'body' %} {% block 'body' %}
{% endblock %} {% 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;
}