ProgrammingError: relation 'blah blah' does not exist, trying to run the specific migration and get error

后端 未结 1 1879
灰色年华
灰色年华 2020-12-12 07:25

I am getting an error:

$ python manage.py migrate swsite 0023_hitcounter.py

Traceback (most recent call last):
  File \"manage.py\", lin         


        
相关标签:
1条回答
  • 2020-12-12 08:17

    The traceback is showing you that the error is occuring in IndexView. You are trying to create objects in the database when the view loads.

    class IndexView(TemplateView):
        newhit = HitCounter.objects.create()  # remove this line
        ...
    

    Accessing the database when the views load like this is a bad idea, so you should probably remove the line. In production, it gives you the error because it is trying to create the object in the database before you have applied the migration that creates the table.

    0 讨论(0)
提交回复
热议问题