Skip to content
Advertisement

Generating new unique uuid4 in Django for each object of Factory class

I have a Model Sector which has a id field (pk) which is UUID4 type. I am trying to populate that table(Sector Model) using faker and factory_boy.

But,

JavaScript

This is the error I am getting.

Is it possible that the error is due to the fact that everytime I am creating SectorFactory objects (which is in a different django app) and the seed gets reset to some previous number causing the uuid to repeat?

Please suggest some ways as to how I shall get unique uuid for each Factory object?

SectorFactory class

JavaScript

Class Sector

JavaScript

The script which creates the custom command to create SectorFactory objects.

JavaScript

Advertisement

Answer

just use like this:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement