Skip to content

Instantly share code, notes, and snippets.

@benjaminws
Forked from anonymous/ImmutableModel.py
Last active December 10, 2015 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjaminws/4383040 to your computer and use it in GitHub Desktop.
Save benjaminws/4383040 to your computer and use it in GitHub Desktop.
from base import BaseImmutable
class ImmutableModel(BaseImmutable):
def __init__(self, django_model):
temp_dict = {}
for field in django_model._meta.fields:
temp_dict[field.name] = getattr(django_model,field.name)
self.__dict__ = temp_dict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment