Open opentyler opened 4 years ago
I ran into this as well. I tracked it down to the ulid.new
function returning an object which I guess makes django unhappy. if i make my own function and coerce it to a string then everything works as expected
from django_ulid.models default as default_ulid
def new_ulid():
return str(default_ulid())
then pass new_ulid
to default
Awesome, thanks for the heads up. This solution worked beautifully for me too. Cheers!
My apologies for the delay, I missed the notifications for this issue.
A few versions back, support for monotonic randomness was added to ulid-py. This made the randomness implementation pluggable and the exported API is now bound methods on a constant object instead of pure functions as before.
I'll look to see if I can expose a pure function from django-ulid
to make this easier for downstream consumers.
There is even a bug report to Django for it from someone.
I understand this is an issue originating from a downstream project, however this prevents anyone from using django-ulid
without doing the workaround given by @gmjosack above and just cost me a few hours trying to figure out why in the world these identical migrations were being created.
I'd be happy to provide a patch for this so this works out-of-the-box again if you can point me in the correct direction @ahawker.
I'm using ULID as the primary key for a couple of my models, as well as ULID for a couple non-PK keys. When i run python manage.py makemigrations, a migration is made attempting to redeclare the ulid fields being used as pk, but the non-pk fields aren't affected which is good. If I try to run the migration, it results with an error, reproduced below.
Not sure why django wants to keep creating this migration, as its the exact same operation as the initial migration.
models.py:
Initial migration:
Migration that keeps getting recreated every time I run python manage.py makemigrations:
The error I get if I try to run this superfluous migration: