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
Post a Comment