'relation " " does not exist in Django
I have a doubt what does it mean:
relation "clientes" does not exist
LINE 1: select nombre from Clientes where joindate between "2022-02-...
It seems strange to me; or that this error appears since my model is called Customers; I just did the migrations on heroku, but I get this error
In my views I have this:
def list_clientes(request):
if request.method == 'POST':
fromdate=request.POST.get('fromdate')
todate = request.POST.get('todate')
searchresult=Clientes.objects.raw('select nombre from Clientes where joindate between "'+fromdate+'" and "'+todate+'"')
return render(request,'Clientes/clientes-list.html',{'clientes':searchresult})
else:
displaydata = Clientes.objects.all()
return render(request, 'Clientes/clientes-list.html', {'clientes': displaydata})
models.py
class Clientes(models.Model):
tipo = models.CharField(max_length=200)
nombre = models.CharField(max_length=200)
fecha_registro = models.DateTimeField(default=datetime.now)
def __str__(self):
return f'{self.nombre}'
settings.py
DATABASES = {
'default': {
'ENGINE':'django.db.backends.postgresql_psycopg2',
'NAME':'sistemacarros_db',
'USER':'postgres',
'PASSWORD':'1234',
'HOST':'localhost',
'PORT':'5432',
'OPTIONS':{
'init_command':"SET sql_mode='STRICT_TRANS_TABLES'",
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
