python - How to Fake django.contrib.auth User value for specific user? -


i writing script , want fake user id (pk) of 2

var = table(fktouser=2) var.save() 

the problem i'm getting :

"table.fktouser" must "user" instance 

i've verified auth_user has record id=2

how can fake 2 value testing purposes?

thank you!

assuming table model , fktouser foreign key, there 2 ways. first set fktouser_id attribute 2 , save model. other fetch user , set fktouser attribute right user model instance.

this how foreign key works. actual column in database fktouser_id column, , it's simple integer foreign key id in column. django magic makes possible automatically retrieve right instance accessing fktouser, , set right value assigning model instance fktouser.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -