Reputation: 18353
I'd like to use the OneToOneField model field, with the user ID as the foreign key. For example:
owner_id = models.OneToOneField("User.id")
But, I get this error:
'owner_id' has a relation with model User.id, which has either not been installed or is abstract.
I've also tried with Users.id.
Upvotes: 0
Views: 1009
Reputation: 188
Try this
owner_id = models.OneToOneField(User)
here is an example
Upvotes: 1
Reputation: 47172
You don't put in the User.id
(since User.id
is not a model) but simply supply the User
model.
class ToySoldier(models.Model):
user = models.OneToOneField(User)
and Django will handle the rest itself.
Upvotes: 2