[Fixed]-How to fix "InternalError: variable not found in subplan target list"


It appears postgres has shipped something broken into all their minor versions:


For example, the postgres:12 dockerhub is now the same as the postgres:12.10 dockerhub image rather than 12.9. If you explicitly specify postgres:12.9 (or the previous minor release for any of the other versions), I believe it will start working.


To temporarily fix the Issue – for me a VACUUM FULL; helped.

To really resolve the issue you have to update Postgresql to a newer version I guess.


I had the same issue. Temporary fix but what I did was modify the query performed by the admin.

Try this in your admin.py

class ProblemAdmin(admin.ModelAdmin):
    def get_queryset(self, request):
        return Problem.objects.filter(id__gte=0)

Edit: This only fixes issues you may have with your django admin

Leave a comment