from django.utils.encoding import smart_unicode
from .base import Plugin
from ..extdirect import ext_action, ext_method
-import operator, staticmedia
+import operator
@ext_action(name='models')
@property
def index_js_urls(self):
return super(Models, self).index_js_urls + [
- staticmedia.url('gilbert/extjs/examples/ux/SearchField.js'),
- staticmedia.url('gilbert/plugins/models.js'),
+ settings.STATIC_URL + 'gilbert/extjs/examples/ux/SearchField.js',
+ settings.STATIC_URL + 'gilbert/plugins/models.js',
]
@property
def data_serialize_model_instance(cls, obj):
return {
'app_label': obj._meta.app_label,
- 'name': obj._meta.object_name,
+ 'name': obj._meta.module_name,
'pk': obj.pk,
'__unicode__': unicode(obj),
}
@property
def data_columns_spec(self):
spec = []
+
for field_name in self.data_columns:
column = {
'dataIndex': field_name,
column['sortable'] = True
if field_name in self.data_editable_columns:
column['editable'] = True
+ if field_name in [field.name for field in self.model_meta.fields if isinstance(field.rel, ManyToOneRel)]:
+ column['xtype'] = 'foreignkeycolumn'
spec.append(column)
return spec