[Answered ]-Creating a new instance of a Custom User Model in Django

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= '...', or model can’t parse which field you will store.

  • user_id

    It has defined foreignkey in advance. It can accept another model object to store: user_id = user. Don’t call attribute of the user to store in LibraryUser.

Leave a comment