5

I'm trying to generate a new database with uuid using django and postgresql

I have a model with UUID field like this :

 class BaseUser(AbstractBaseUser):
     id = models.UUIDField(_('id'), primary_key=True, default=uuid.uuid4, editable=False)

When i try to syncdb i got the following error :

django.db.utils.ProgrammingError: column "id" cannot be cast automatically to type uuid HINT: Specify a USING expression to perform the conversion.

I already try to modify the type by hand doing:

CREATE EXTENSION "uuid-ossp";
ALTER TABLE baseuser ALTER COLUMN id SET DATA TYPE UUID USING (uuid_generate_v4());

end up with this error:

ERROR: default for column "Id" cannot be cast automatically to type uuid

I also tried sqlite without success

I just want to generate a new db with uuid, I don't care about existing data.

2
  • This might help. stackoverflow.com/questions/20342717/… Commented Oct 27, 2015 at 17:58
  • 2
    Yes thanks, i finally end up deleting all past migrations and it work. Commented Oct 27, 2015 at 18:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.