python - I wanna assign trunsaction_id each user_id -


i wanna assign trunsaction_id each user_id.now user model is

class user(models.model):     trunsaction_id = models.uuidfield(primary_key=true, default=uuid.uuid4, editable=false)     regist_date = models.datetimefield(auto_now=true)     user_id = models.charfield(max_length=200,null=true)     name = models.charfield(max_length=200,null=true)     age = models.charfield(max_length=200,null=true) 

when run code,trunsaction_id assigned in turn of registration. possible assign trunsaction_id each user_id?if answer yes,i wanna know way. example,if user_id 1,trunsaction_id 1 of connected user_id &trunsaction_id in under score 1_randomly trunsaction_id .is possible?if answer no,is there way assign trunsaction_id each user_id?

it's not clear trying accomplish.

if trying use composite primary key, not supported django. see documentation here.

if trying column 2 fields combined, try solution below.

however depending on need may better off doing in querysets. please clarify trying achieve.

class user(models.model):     trunsaction_id = models.uuidfield(primary_key=true, default=uuid.uuid4, editable=false)     regist_date = models.datetimefield(auto_now=true)     user_id = models.charfield(max_length=200,null=true)     name = models.charfield(max_length=200,null=true)     age = models.charfield(max_length=200,null=true)      @property     def composite(self):         return self.user_id + "_" + self.trunsaction_id  

Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -