2
You should assign value to the specify fields as the following:
lu = LibraryUser(library_membership_number= '...', user_id = user)
lu.save()
-
library_membership_number
You can’t just assign a variable to
library_membership_number
.model
is a object containing the fields. You should appoint the field and assign it:library_membership_number= '...'
, ormodel
can’t parse which field you will store. -
user_id
It has defined
foreignkey
in advance. It can accept anothermodel
object to store:user_id = user
. Don’t call attribute of theuser
to store inLibraryUser
.
Source:stackexchange.com