Add FuelPurchase model, List, Create views and templates

This commit is contained in:
Nyymix 2025-08-09 20:23:30 +03:00
parent 64576a7f09
commit fa19b593d8
10 changed files with 242 additions and 4 deletions

View file

@ -1,6 +1,25 @@
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 = "/"