英文:
Getting a problem after deploy a Django app on Render
问题
我使用Django开发了一个应用,使用PostgreSQL作为数据库,在本地环境中它可以正常运行,但是当部署到Render.com上时,应用抛出了这个错误。
我不得不将调试模式设置为True以查看错误。
这是Render控制台显示的信息:
django.db.utils.ProgrammingError: 表 "management_notificacion" 不存在
Jun 28 04:55:41 PM LINE 1: SELECT COUNT(*) AS "__count" FROM "management_notificacion" ...
以下是出错的代码行,但在本地环境中可以正常工作。
context_processors.py
from management.models import *
def get_notificaciones(request):
notificaciones = Notificacion.objects.filter(receptor=request.user.id)[:3]
no_vistas = Notificacion.objects.filter(receptor=request.user.id, visto=False).count()
return {
'notificaciones': notificaciones,
'no_vistas': no_vistas
}
def get_mensajes(request):
mensajes = Mensaje.objects.filter(receptor=request.user.id)[:4]
no_vistos = Mensaje.objects.filter(receptor=request.user.id, visto=False).count()
return {
'mensajes': mensajes,
'no_vistos': no_vistos
}
如果有人能提供解决方法的线索,我将非常感激!
英文:
I developed an app in Django using PostgreSQL as DataBase, on a local environment it works without problems, but when it was deployed on Render.com it the app throws me this error.
I had to set the debug in True to watch the error
This is that Render console shows me:
django.db.utils.ProgrammingError: relation "management_notificacion" does not exist
Jun 28 04:55:41 PM LINE 1: SELECT COUNT(*) AS "__count" FROM "management_notificacion" ...
This is the line of code that is given the error, but in local works without problems
context_processors.py
from management.models import *
def get_notificaciones(request):
notificaciones = Notificacion.objects.filter(receptor=request.user.id)[:3]
no_vistas = Notificacion.objects.filter(receptor=request.user.id, visto=False).count()
return {
'notificaciones': notificaciones,
'no_vistas': no_vistas
}
def get_mensajes(request):
mensajes = Mensaje.objects.filter(receptor=request.user.id)[:4]
no_vistos = Mensaje.objects.filter(receptor=request.user.id, visto=False).count()
return {
'mensajes': mensajes,
'no_vistos': no_vistos
}
If anyone can give a hint to solve this, I'll be so grateful!
答案1
得分: 1
错误提示指出管理应用程序中通知模型的数据库表不存在。也许您需要迁移管理应用程序。
尝试: python manage.py makemigrations management
。
然后: python manage.py migrate management
。
英文:
The error says that the database table for the Notification model in the management app doesn't exist. maybe you have to migrate the management app .
try : python manage.py makemigrations management
.
then : python manage.py migrate management
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论