I just had this issue and wanted to add info. In fixing the problem I wrapped my head around this via migrations. Anyone who can add to this, please feel free, corrections included.
This app is using Django 1.11, Py3, and was migrating away form early local dev on SQLite (just to proof of concept a few things). When migrating into PG I had the same error :
ERROR: operator class "varchar_pattern_ops" does not accept data type uuid
I was able to fix it 2 ways. In my early stage of the app I was able to wipe and start from scratch. I know this is rarely an option, but my actions provide helpful clues for fixing this in a migration or upgrade scenario. I have good SQL/PG chops coming form the time when ORM use was not common. The issue was a real head scratcher for me.
The Problem
In my 5 year old brain the issue came via changing column types, going from a string-ish to a UUID "native". Via the migrations in my application there seemed to be creation of a column that is not UUID native. With the introduction of Django's model UUIDField
the demand was not able to be met and threw the aforementioned error. The issue is akin to doing something silly moving from str to int type in the DB with non-int values.
Fix Info
I was able to fix this 2 ways.
First was via Django's squash migration. I have already encountered a similar error related to UUID use in my app, so I was aware of this pattern of error. By squashing the migration you skip the earlier non-UUIDField column creation and only perform the correct column declaration. When I re-ran (fresh) migrate
all went just fine.
The second way is hardly a variation, but I killed all migrations and started from the current state. Same effect as the previous.
So..
With all of that said, for me I was able to reverse engineer the issue in a way that works in my head. The "fix" was to never make a column other than the UUIDField friendly way. My issue was related to the SQLite to PG swap (AFIK).
If I was doing an upgrade I think the solutions of killing index(s) and the recreating them is the way to go.
Again, just trying to put a little info out there on this error, the googleweb was not returning anything that really caught me. So I got out the pickaxe and flash light.