python - Django: Assign user name to object -


i'm developing little app i'm having trouble adding username of current user object.

i have defined "message" model "author" property

author = models.foreignkey(user)

then on view, have:

message.author = request.user.username 

but when running app , adding message, this: "cannot assign "'jose'": "message.author" must "user" instance." ("jose" username)

what doing wrong?

you must use:

message.author = request.user 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -