Code

Opened 7 years ago

Closed 6 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:

Description

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.: http://tinyurl.com/ykxjgs

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.

Attachments (0)

Change History (3)

comment:1 Changed 7 years ago by adrian

  • Summary changed from Model object as dict to [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 7 years ago by adrian

  • Summary changed from [design-q] Add as_dict() method to models to Add as_dict() method to models
  • Triage Stage changed from Unreviewed to Design decision needed

comment:3 Changed 6 years ago by SmileyChris

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

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.