I've defined a User
class which (ultimately) inherits from models.Model
. I want to get a list of all the fields defined for this model. For example, phone_number = CharField(max_length=20)
. Basically, I want to retrieve anything that inherits from the Field
class.
I thought I'd be able to retrieve these by taking advantage of inspect.getmembers(model)
, but the list it returns doesn't contain any of these fields. It looks like Django has already gotten a hold of the class and added all its magic attributes and stripped out what's actually been defined. So... how can I get these fields? They probably have a function for retrieving them for their own internal purposes?