Opened 11 years ago

Closed 10 years ago

#3294 closed enhancement (fixed)

Add as_dict() method to models

Reported by: Jeff Bauer <jbauer@…> Owned by: nobody
Component: Core (Other) Version: master
Severity: normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


I'd like to request an as_dict() method to be added to Model. People are treating __dict__ as a way to access the model instance data, e.g.:

It would be better to have a public method so code won't break if __dict__ were to ever be used internally in ways the application developer didn't anticipate.

Change History (3)

comment:1 Changed 11 years ago by Adrian Holovaty

Summary: Model object as dict[design-q] Add as_dict() method to models

I'm always hesitant to add methods to model instances. We'll have to give this some thought.

I'm putting [design-q] in the ticket summary to designate "a design decision needs to be made here."

comment:2 Changed 11 years ago by Adrian Holovaty

Summary: [design-q] Add as_dict() method to modelsAdd as_dict() method to models
Triage Stage: UnreviewedDesign decision needed

comment:3 Changed 10 years ago by Chris Beaven

Resolution: fixed
Status: newclosed

Newforms-admin adds an initial_data method which handles this. I'll preemptively mark as fixed because it's not worth doing anything else in this ticket. See also #5126

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