I
I
Ivan2015-07-31 17:15:11
Django
Ivan, 2015-07-31 17:15:11

Is it possible to create a User instance specifying only pk?

there is a model

class Test(models.Model):
    user = models.OneToOneField(User)
    text = models.TextField()

Is it possible to somehow create an object, assign the user PK field?
For example
Test(user=1, text='123')
Tried through lookup, it doesn't work either :/Test(user__pk=1, text='123')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
un1t, 2015-07-31
@ATNC

Test(user_id=1, text='123')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question