﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
9903	Model._meta._name_map is missing unless you load an object from the database	pavlo@…	nobody	"I need to be able to validate that input parameters are the same length as the max_length field. I figured out how to get back the field object use {{{Model._meta.get_field_by_name()}}}, but I still want to be able to check whether the field exists before I call that method. My code uses {{{Model._meta._name_map}}}, but it doesn't look like it is instantiated until '''after''' you load an object from the database. This seems wrong to me, considering that it is suppose to be an attribute on the model class and not dependent on a particular 

In my example below, I show you can't get to {{{_meta._name_map}}} until after you load an object:


{{{
In [1]: from graffiti.models import *

In [2]: len(Replica._meta._name_map)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/pavlo/Documents/Graffiti/graffiti/src/tracker/<ipython console> in <module>()

AttributeError: 'Options' object has no attribute '_name_map'

In [3]: replica = Replica()

In [4]: len(Replica._meta._name_map)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/pavlo/Documents/Graffiti/graffiti/src/tracker/<ipython console> in <module>()

AttributeError: 'Options' object has no attribute '_name_map'

In [5]: replica = Replica.objects.get(id=1)

In [6]: len(Replica._meta._name_map)
Out[6]: 19
}}}"		closed	Uncategorized	1.0		invalid			Unreviewed	0	0	0	0	0	0
