1 2 3 4 5 6 7 8 9 10 11 12 | ################################################################################
try:
import models as this_db
for item in dir(this_db):
try:
obj = getattr(this_db, item)
if type(obj) == models.base.ModelBase:
fields = dict((f.name, f) for f in obj._meta.fields)
setattr(obj._meta, 'field_map', fields)
except:{}
except:{}
################################################################################
|
More like this
- User Profile minimal code by Natim 1 year, 9 months ago
- ImageField with per user folder by pigletto 5 years, 4 months ago
- Dynamic tabular inlines with optional drag-n-drop sorting by Aneon 4 years ago
- Database file storage by powerfox 4 years, 3 months ago
- slug filename by willhardy 3 years, 10 months ago
Comments
Or you could just use
_meta.get_field("name"), which has been available since Django's initial public release.#