Opened 14 years ago

Closed 14 years ago

#12338 closed (invalid)

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

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


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 Daniel Hahler 14 years ago.
Patch against trunk

Download all attachments as: .zip

Change History (3)

by Daniel Hahler, 14 years ago

Attachment: django-models-doc.diff added

Patch against trunk

comment:1 by Alex Robbins, 14 years ago

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 by Alex Robbins, 14 years ago

Resolution: invalid
Status: newclosed

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