autoilux/main/views.py

25 lines
658 B
Python

from django.http import HttpResponse
from django.shortcuts import render
from django.urls import reverse_lazy
from django.views.generic import CreateView, ListView
from .forms import FuelPurchaseForm
from .models import FuelPurchase
def index(request):
return HttpResponse("Hello, world.")
class FuelPurchaseListView(ListView):
model = FuelPurchase
template_name = "main/fuelpurchase_list.html"
context_object_name = "purchases"
ordering = ['-purchase_date']
class FuelPurchaseCreateView(CreateView):
model = FuelPurchase
form_class = FuelPurchaseForm
template_name = "main/fuelpurchase_add.html"
success_url = "/"