Opened 10 years ago

Closed 10 years ago

Last modified 7 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 10 years ago by Jeff Anderson

Component: UncategorizedDatabase wrapper
milestone: 1.0
Triage Stage: UnreviewedAccepted

comment:2 Changed 10 years ago by Collin Grady

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 10 years ago by omat@…

Resolution: invalid
Status: newclosed

You are right, FK should be excluded from start.

comment:4 Changed 7 years ago by Jacob

milestone: 1.0

Milestone 1.0 deleted

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