views: explorando plantillas.
This commit is contained in:
parent
70a70f6620
commit
c2755e1adc
@ -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>
|
@ -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 %}
|
@ -3,6 +3,7 @@ from django.urls import path
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("comprar", views.buy, name="buy"),
|
|
||||||
path("", views.index, name="wellcome"),
|
path("", views.index, name="wellcome"),
|
||||||
|
path("comprar", views.buy, name="buy"),
|
||||||
|
path("compras", views.purchases, name="purchases"),
|
||||||
]
|
]
|
||||||
|
@ -1,8 +1,20 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
from django.template import loader
|
||||||
|
|
||||||
|
from .models import Sale
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
return HttpResponse("<h1>Don Confiado</h1></br><a href='./comprar'>Comprar</a>")
|
template = loader.get_template('don_confiao/index.html')
|
||||||
|
return HttpResponse(template.render({}, request))
|
||||||
|
|
||||||
def buy(request):
|
def buy(request):
|
||||||
return HttpResponse("Nombre: ....")
|
return HttpResponse("Nombre: ....")
|
||||||
|
|
||||||
|
def purchases(request):
|
||||||
|
purchases = Sale.objects.all()
|
||||||
|
template = loader.get_template('don_confiao/purchases.html')
|
||||||
|
context = {
|
||||||
|
"purchases": purchases,
|
||||||
|
}
|
||||||
|
return HttpResponse(template.render(context, request))
|
||||||
|
Loading…
Reference in New Issue
Block a user