Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#7585 closed (invalid)

changeset 7574 broke on FK fields

Reported by: omat@… Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


When trying to save a ModelForm instance with a not null foreign key without specifying the FK field but saving with commit=False

raises ValueError as per the following code introduced in the changeset [7574]:

        if value is None and self.field.null == False: 
 		            raise ValueError('Cannot assign None: "%s.%s" does not allow null values.' % 

commit=False should be regarded when checking for ValueError.

Change History (4)

comment:1 Changed 8 years ago by programmerq

  • Component changed from Uncategorized to Database wrapper
  • milestone set to 1.0
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 8 years ago by cgrady

I don't see the use case where this would present itself - if you have a ForeignKey you're setting manually, wouldn't you use exclude to hide it from the form entirely, so it is therefore not being set at all in save() ?

comment:3 Changed 8 years ago by omat@…

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

You are right, FK should be excluded from start.

comment:4 Changed 5 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top