0

I am trying to make a user login page in Django following the book "How to Tango with Django" (for the most part). My form appears on the template as it should but upon submission I get the following errors:

'function' object has no attribute 'save'

'function' object has no attribute 'set_password'

The relevant part of my view function is as follows:

   if user_form.is_valid() and profile_form.is_valid():
        user = user_form.save
        user.set_password(user.password)
        user.save()
        profile = profile_form.save(commit=False)
        profile.user = user

My model is:

class UserProfile(models.Model):
    user = models.OneToOneField(User)
    picture = models.ImageField(upload_to='profile_pictures', 
    blank=True)

    def __str__(self):
        return self.user.username
0

1 Answer 1

1

You're not calling it as a function. You're using user = user_form.save but you want user = user_form.save() and if you don't want to commit it, user = user_form.save(commit=False)

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much. Those darn parentheses!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.