#36963 closed Cleanup/optimization (invalid)

JSONField("ContactInfo", default=contact_default) i think you need to discribe more about the passed function

Reported by: yousef_fadli Owned by:
Component: Documentation Version: 6.0
Severity: Normal Keywords:
Cc: yousef_fadli Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

https://docs.djangoproject.com/en/6.0/ref/models/fields/#default

i think you need to describe more about the function in default=contact_default.

The question is :
If this function is defined inside the actual class, should it be a static method or a class method or a normal object method ?
thanks

Change History (2)

in reply to:  description comment:1 by Shubh Rai, 27 minutes ago

The documentation says that the callable must expect no arguments. Django invokes it without passing self or cls, defining it as a normal instance method or class method would not work unless extra wrapping is used.

Therefore, if the callable is defined inside the model class, it would need to be a @staticmethod, or alternatively be defined at module level.

comment:2 by Clifford Gama, 24 seconds ago

Resolution: invalid
Status: newclosed

Closing per https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels since I think the docs are pretty clear here.

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