0
I’m developing a parking management system in Django that registers the 'Vehicle' object according to its time of entry, and calculates the value as it goes, but I need to develop a reporting system that returns how many cars came in and the total value of the day.
How can I get access to the vehicles that left the parking, because after the exit record, the object is deleted in the database.
# models.py
class Veiculo(models.Model):
marca = models.CharField(max_length=100, null=False)
modelo = models.CharField(max_length=100, null=False)
cor = models.CharField(max_length=50, null=False)
placa = models.CharField(max_length=8, null=False)
horario = models.DateTimeField(auto_now_add=True, null=False)
def __str__(self):
return self.placa
class ValorEstacionamento(models.Model):
periodoManha = MoneyField(max_digits=14, decimal_places=2,
default_currency='BRL', default='2')
periodoTarde = MoneyField(max_digits=14, decimal_places=2,
default_currency='BRL', default='3')
periodoFDS = MoneyField(max_digits=14, decimal_places=2,
default_currency='BRL', default='2.5')
def __str__(self):
return "Tabela de Valores"
# views.py
class EntradaCreateView(CreateView):
model = Veiculo
form_class = InsereVeiculoForm
template_name = 'entrada.html'
success_url = reverse_lazy('sistema:veiculos')
class VeiculosListView(ListView):
template_name = 'veiculos.html'
model = Veiculo
context_object_name = 'veiculos'
def saida(request, placa):
veiculo = get_object_or_404(Veiculo, placa=placa)
veiculo.delete()
return render(request, 'index.html')
# forms.py
class InsereVeiculoForm(forms.ModelForm):
class Meta:
model = Veiculo
fields = [
'marca',
'modelo',
'cor',
'placa',
]
Missing data, where vehicle entry class and vehicle exit class
– jallisson jallis oliveira band
I performed the entry and exit of the vehicles in
views.py
– ls bash