Skip to content

Commit

Permalink
remove comment with link to Django snippet 1040
Browse files Browse the repository at this point in the history
* the snippet was removed since it's now obsolete - the new Django Meta
 o\Options API has new methods, _eg_: `get_fields()`, to get fields, to
 filter out parent, autogenerated and reverse fields from a model
* add new comment that links to new Django Meta Options API
  • Loading branch information
mikofski committed Oct 31, 2016
1 parent 50b94d2 commit f9b396e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion carousel/contrib/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@

def copy_model_instance(obj):
"""
https://djangosnippets.org/snippets/1040/
Copy Django model instance as a dictionary excluding automatically created
fields like an auto-generated sequence as a primary key or an auto-created
many-to-one reverse relation.
:param obj: Django model object
:return: copy of model instance as dictionary
"""
meta = getattr(obj, '_meta') # make pycharm happy
# dictionary of model values excluding auto created and related fields
Expand Down

0 comments on commit f9b396e

Please sign in to comment.