Merge pull request 'exploring_views' (#1) from exploring_views into main

Reviewed-on: OneTeam/don_confiao#1
This commit is contained in:
Cosmos 2024-06-29 09:18:09 -05:00
commit 764d3d8d85
5 changed files with 42 additions and 2 deletions

View File

@ -0,0 +1,6 @@
<h1>Tienda la Ilusión</h1>
<h2>Don Confiao</h2>
<ul>
<li><a href='./comprar'>Comprar</a></li>
<li><a href='./compras'>Compras</a></li>
</ul>

View File

@ -0,0 +1,9 @@
{% if purchases %}
<ul>
{% for purchase in purchases %}
<li><a href="/don_confiao/{{ purchase.id }}/">{{ purchase.date }}, {{ purchase.customer }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No hay Compras</p>
{% endif %}

View File

@ -0,0 +1,9 @@
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="wellcome"),
path("comprar", views.buy, name="buy"),
path("compras", views.purchases, name="purchases"),
]

View File

@ -1,3 +1,18 @@
from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader
# Create your views here.
from .models import Sale
def index(request):
return render(request, 'don_confiao/index.html')
def buy(request):
return HttpResponse("Nombre: ....")
def purchases(request):
purchases = Sale.objects.all()
context = {
"purchases": purchases,
}
return render(request, 'don_confiao/purchases.html', context)

View File

@ -15,8 +15,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import include, path
urlpatterns = [
path("don_confiao/", include("don_confiao.urls")),
path('admin/', admin.site.urls),
]