python - Access Users Model foreign Key -


i writing first django app wanting utilise built in user model map own custom model.

my application going manage users devices. this, have table called devices. wanting foreign key per device maps user model (so 1 user can have multiple devices).

my question is, how add mapping in model. thing?

class devices(model.model):  deviceid = model.charfield(maxlength=10)  owner = model.foreignkey(<user??>) 

thanks in advance,

paul

class device(model.model):     deviceid = model.charfield(maxlength=10)     owner = model.foreignkey(user) 

after model related via foreignkey can following actions, if have device object in variable called dev:

dev.owner  # return user object, can access user fields dev.owner.username dev.owner.email 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -