Checking for duplicate with newforms

2007-11-07 Thread [EMAIL PROTECTED]
I have a public-facing form where registered users can submit clubs. Later, I access the data by slug, using a generic object_detail view. My problem is that someone can input a club that's already there. Besides polluting the database, it breaks when they try to access the club's page (GET retur

Re: Checking for duplicate with newforms

2007-11-07 Thread [EMAIL PROTECTED]
Here's what I've done: if request.method == 'POST': submission = request.POST.copy() submission['slug'] = slugify(submission['name']) form = ClubFormClass(submission) if Club.objects.get(slug=submission['slug']): form.errors['name'] = 'Club is already in

Re: Checking for duplicate with newforms

2007-11-07 Thread Jonathan Buchanan
[EMAIL PROTECTED] wrote: > Here's what I've done: > > if request.method == 'POST': > submission = request.POST.copy() > submission['slug'] = slugify(submission['name']) > form = ClubFormClass(submission) > if Club.objects.get(slug=submission['slug']): > f

Re: Checking for duplicate with newforms

2007-11-07 Thread [EMAIL PROTECTED]
On Nov 7, 1:53 pm, Jonathan Buchanan <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Here's what I've done: > > > if request.method == 'POST': > > submission = request.POST.copy() > > submission['slug'] = slugify(submission['name']) > > form = ClubFormClass(subm

Re: Checking for duplicate with newforms

2007-11-07 Thread Jonathan Buchanan
[EMAIL PROTECTED] wrote: > > > On Nov 7, 1:53 pm, Jonathan Buchanan <[EMAIL PROTECTED]> > wrote: >> [EMAIL PROTECTED] wrote: >>> Here's what I've done: >>> if request.method == 'POST': >>> submission = request.POST.copy() >>> submission['slug'] = slugify(submission['name']) >>>