Initial plant reference and basic login
This commit is contained in:
parent
a2dba58fe4
commit
cada3c7357
31 changed files with 637 additions and 0 deletions
21
planterteque/views.py
Normal file
21
planterteque/views.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
from django.http import HttpResponse, Http404
|
||||
from django.template import loader
|
||||
|
||||
from .models import Plant
|
||||
|
||||
def index(request):
|
||||
latest_plants_list = Plant.objects.order_by("-create_date")[:5]
|
||||
context = { "latest_plants_list": latest_plants_list }
|
||||
return render( request, "planterteque/index.html", context )
|
||||
|
||||
def reference(request, plant_id):
|
||||
try:
|
||||
plant = Plant.objects.get( pk=plant_id )
|
||||
except Plant.DoesNotExist:
|
||||
raise Http404("Plant does not exist")
|
||||
context = { "plant": plant }
|
||||
return render( request, "planterteque/reference.html", context )
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue