On Sun, Apr 6, 2008 at 1:38 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > The way I would handle it is in the save method of the invitation > model I would do: > def save(self, *args, **kwargs): > if not self.pk: > #This is a new invite, we need to generate the code > self.hash = do_something_to_generate_the_hash > super(Invite, self).save(*args, **kwargs)
Thanks Alex! Overriding the save had occurred to me. I wasn't sure if there was something more built-in. I'm still not sure that my plan is the best way. I'm always wary of sending emails from the system to addresses which people have not knowingly provided. /alex > > On Apr 6, 1:31 pm, "Alex Ezell" <[EMAIL PROTECTED]> wrote: > > My use case is that I need to send invites via email to people. These > > are not site users, but are people being invited to join the site (and > > a particular group on this site) by current users. So, I can't ask > > them to login, because I have no data about them. > > > > They would then click the link in the email and the site would use the > > random hash value in the url to look up the invite and then do > > whatever else it needs to do for that type of invitation. > > > > I'm doing this so that there is at least a modicum of protection from > > someone just incrementing the values in the URL to mess with the > > invite system. It, by no means, needs to be "secure" which this method > > would clearly not be. > > > > Think of the model of a member of a Facebook group entering a friend's > > email and inviting them to join the group. But that friend may or may > > not be a user of the site. > > > > My question is: What's the best way to create this random hash when > > the invitation is saved? Can I do it with some default in the model? > > > > I'd also welcome any perspective on handling this use case better. > > I've only just begun thinking through it. > > > > Thanks! > > > > Alex > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---