'Problems using createview on heroku
I was working locally and 3 Create Views worked perfectly for me to upload data. I passed it to Heroku and sadly out of the 3, only one CreateView works for me, any idea what it could be?
I already reviewed the code and it is very similar both in views and in the template.
The problem is that when I click the save button it doesn't do anything, it doesn't save anything and it doesn't take me to any link, but it seems strange to me that locally it worked quite well and not on heroku
models
class Carro(models.Model):
placas=models.CharField(max_length=255)
año=models.IntegerField()
marca=models.CharField(max_length=255)
modelo=models.CharField(max_length=255)
tipo=models.CharField(max_length=255)
motor=models.CharField(max_length=255, default='0')
vin=models.CharField(max_length=255)
color=models.CharField(max_length=255)
agente_seguros=models.CharField(max_length=255)
compañia_seguros=models.CharField(max_length=255)
no_politica=models.CharField(max_length=255)
cliente= models.ForeignKey(Clientes, on_delete=models.SET_NULL, null=True)
def __str__(self):
return f'{self.placas} {self.año}{self.marca} {self.modelo} {self.tipo}{self.motor}{self.vin}{self.color}' \
f'{self.agente_seguros}{self.compañia_seguros}{self.no_politica}{self.cliente}'
views
class create_carros(CreateView):
model=Carro
form_class=CarroForm
template_name='carros/carros-form-add.html'
success_url=reverse_lazy('carros:list_cars')
forms
class CarroForm(forms.ModelForm):
class Meta:
model=Carro
fields='__all__'
widgets = {
'placas': forms.TextInput(
attrs={
'class': 'form-control',
}
),
'año': forms.TextInput(
attrs={
'class': 'form-control'
}
),
'marca': forms.TextInput(
attrs={
'class': 'form-control'
}
),
'modelo': forms.TextInput(
attrs={
'class': 'form-control'
}
),
'tipo': forms.TextInput(
attrs={
'class': 'form-control'
}
),
'vin': forms.TextInput(
attrs={
'class': 'form-control'
}
),
'color': forms.TextInput(
attrs={
'class': 'form-control'
}
),
'agente_seguros': forms.TextInput(
attrs={
'class': 'form-control'
}
),
'compañia_seguros': forms.TextInput(
attrs={
'class': 'form-control'
}
),
'no_politica': forms.TextInput(
attrs={
'class': 'form-control'
}
),
'cliente': forms.Select(
attrs={
'class': 'form-select'
}
),
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
