Created
May 15, 2014 17:28
-
-
Save cansadadeserfeliz/d259e12b1b0b10c47d59 to your computer and use it in GitHub Desktop.
Django: get a list of fields for instance of a model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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