Opened 7 years ago

Closed 7 years ago

#12338 closed (invalid)

"Overriding predefined model methods": use *args, **kwargs in code sample

Reported by: blueyed Owned by: nobody
Component: Documentation Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


The "Overriding predefined model methods" section in the models doc provides sample code to override save, and I think that the code should use "*args, kwargs" so that your own implementation is future proof.

I'm attaching a patch for docs/topics/db/models.txt

Attachments (1)

django-models-doc.diff (1.3 KB) - added by blueyed 7 years ago.
Patch against trunk

Download all attachments as: .zip

Change History (3)

Changed 7 years ago by blueyed

Patch against trunk

comment:1 Changed 7 years ago by alexr

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I'm not sure that you want to pass through all args and kwargs. If I pass anything other than force_insert or force_update to my function then I will get TypeError (unexpected keyword argument) when that argument is passed into the model's save method. The model's save method doesn't accept kwargs, so passing that to it is asking for trouble.

Just my 2 cents.

comment:2 Changed 7 years ago by alexr

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

I'm going to set this invalid since I think it won't work. Feel free to set it back if I am wrong.

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