[Answer]-Why do I get AttributeError: 'User' object has no attribute 'zipcode'?

1πŸ‘

βœ…

As you are aware, and even reiterate in your comment, zipcode is an attribute of MyProfile, not of User. So why are you trying to access it on the user? You need to follow the relationship to the profile:

form.zipcode = request.user.my_profile.zipcode

(Note that β€œform” is a very bad name for the variable there: what you have is an instance of Entry, so perhaps you should name it accordingly.)

Leave a comment