Code

Opened 6 years ago

Closed 5 years ago

Last modified 3 years ago

#8908 closed (fixed)

ModelForms check constraints that they should not.

Reported by: jamiequint Owned by: nobody
Component: Forms Version: 1.0
Severity: Keywords:
Cc: jamie@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

This is a patch for the changes committed in #8209

If you have a ModelForm with extra fields that represent foreign key relationships between models self.instance._meta.get_field_by_name(name) will find a field with the given name and will attempt to check it. However, this will fail because get_field_by_name[0] will return a RelatedObject rather than a form field object like the code is expecting.

The submitted patch checks the value returned by get_field_by_name which returns true when the given field exists on the model, if this value is False it bypasses the check.

Attachments (1)

fix_modelform_unique_check.diff (748 bytes) - added by jamiequint 6 years ago.

Download all attachments as: .zip

Change History (4)

Changed 6 years ago by jamiequint

comment:1 Changed 5 years ago by jacob

  • milestone set to 1.1
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by Alex

  • Resolution set to fixed
  • Status changed from new to closed

This appears to have been fixed by Karen at some point since this was opened: http://code.djangoproject.com/browser/django/trunk/django/forms/models.py#L245 if this is incorrect feel free to reopen.

comment:3 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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.