Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

InviteFriendForm cleaned_data error #7

Open
philomates opened this issue Jun 12, 2009 · 2 comments
Open

InviteFriendForm cleaned_data error #7

philomates opened this issue Jun 12, 2009 · 2 comments

Comments

@philomates
Copy link

When trying to use the InviteFriendForm in such a way:
form = InviteFriendForm(user=request.user)
form.initial['to_user'] = "peter"
form = form.clean()
if form.is_valid():
...

I get the error:
'InviteFriendForm' object has no attribute 'cleaned_data'

If I'm just approaching this from a silly angle, could you please let me know the proper way to use the InviteFriendForm.
Also, usage examples or an overview on the wiki would be very helpful.

thanks

@CarlFK
Copy link

CarlFK commented Nov 9, 2009

'peter' isn't a valid user, and the code doesn't handle that case. this fixes it:

 def clean(self):
  •  if "to_user" in self.cleaned_data:
    
    • to_user = User.objects.get(username=self.cleaned_data["to_user"])

@CarlFK
Copy link

CarlFK commented Nov 9, 2009

OK, that looks lame.
need to add
if "to_user" in self.cleaned_data:

How do I submit a patch?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants