Code

Opened 7 years ago

Closed 7 years ago

#5736 closed (duplicate)

unique fields won't be validated by .is_valid() in NewForms form_for_models

Reported by: packermann@… Owned by: nobody
Component: Forms Version: master
Severity: Keywords: unique is_valid()
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I have some unique-Fields in my models.py. I use form_for_models and form_for_instance to build my forms to populate my DB. For validation I use .is_valid():
Example:

if request.method == 'POST':
		f = ServerForm(request.POST)
		if f.is_valid():
			saveobject = f.save()

If I test this by trying to add a duplicate entry, I get a "duplicate key violates unique constraint" instead of the expected error-message in my forms as for the other validation.
If you need some files, traceback please mail me.

regards

Attachments (0)

Change History (1)

comment:1 Changed 7 years ago by brosner

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

I am closing this as a duplicate of #4895. The reasoning in that ticket is the same for this one as well.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.