Django + PostgreSQL custom auth model

Really taxed on time at the moment, hoping to write this down in detail soon.

The issue I’m hoping to address is when one tries to change the authentication model in a Django/PostgreSQL application after some initial migrations have been made.

This seems to be a known pain point

Since I was mid development and I my database didn’t really hold anything of substance, I didn’t mind resetting the database.

After doing so, running all the migrations at once, the issue seemed to have been resolved. But soon enough, I ran into another issue.

When I reset the database, the Django Admin super user was also removed and when I tried adding one, I was faced with

django.db.utils.DataError: value too long for type character varying(2)

This is really puzzling, I verified by dropping into the PSQL prompt and the password field is a varying(128)

Eventually, I was able create a superuser for Django Admin by using a raw SQL query in the PSQL prompt. However I’m certain that isn’t the appropriate solution for the same.

Things are working fine for now after this hack, but I hope to reopen investigation on this issue sometime again. Until then, this post should act as a “note to self”.

One thought on “Django + PostgreSQL custom auth model

Leave a comment