Skip to content

Instantly share code, notes, and snippets.

@cansadadeserfeliz
Created May 15, 2014 17:28
Show Gist options
  • Save cansadadeserfeliz/d259e12b1b0b10c47d59 to your computer and use it in GitHub Desktop.
Save cansadadeserfeliz/d259e12b1b0b10c47d59 to your computer and use it in GitHub Desktop.
Django: get a list of fields for instance of a model
from django.forms.models import model_to_dict
instance = MyModel.objects.first()
fields = model_to_dict(instance).keys()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment