Add FuelPurchase model, List, Create views and templates
This commit is contained in:
parent
64576a7f09
commit
fa19b593d8
10 changed files with 242 additions and 4 deletions
|
@ -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 = "/"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue