thx for your answer. On Sep 12, 8:47 pm, bruno desthuilliers <bruno.desthuilli...@gmail.com> wrote: > On 11 sep, 18:40, victor <xur...@gmail.com> wrote: > > > can i get model field type from a model queryset in django? > > for example: > > a is b model's queryset > > b model has following field: > > > - f:charfield > > - g:foreignkey > > - h:manytomany > > > is there any way to get field g's type from queryset a? > > br...@bibi ~/playground/foobar $ ./manage.py shell > Python 2.6.2 (r262, Aug 23 2009, 03:12:31) > [GCC 4.1.2 (Gentoo 4.1.2 p1.0.2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > (InteractiveConsole)>>> from truc.models import * > >>> qs = Bidule.objects.all() > >>> dir(qs) > > ['__and__', '__class__', '__deepcopy__', '__delattr__', '__dict__', > '__doc__', '__format__', '__getattribute__', '__getitem__', > '__getstate__', '__hash__', '__init__', '__iter__', '__len__', > '__module__', '__new__', '__nonzero__', '__or__', '__reduce__', > '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', > '__subclasshook__', '__weakref__', '_as_sql', '_clone', '_fill_cache', > '_filter_or_exclude', '_iter', '_merge_sanity_check', > '_next_is_sticky', '_result_cache', '_result_iter', > '_setup_aggregate_query', '_sticky_filter', '_update', 'aggregate', > 'all', 'annotate', 'complex_filter', 'count', 'create', 'dates', > 'defer', 'delete', 'distinct', 'dup_select_related', 'exclude', > 'exists', 'extra', 'filter', 'get', 'get_or_create', 'in_bulk', > 'iterator', 'latest', 'model', 'none', 'only', 'order_by', 'ordered', > 'query', 'reverse', 'select_related', 'update', 'value_annotation', > 'values', 'values_list']>>> qs.model > > <class 'truc.models.Bidule'>>>> qs.model._meta > > <Options for Bidule>>>> dir(qs.model._meta) > > ['__class__', '__delattr__', '__dict__', '__doc__', '__format__', > '__getattribute__', '__hash__', '__init__', '__module__', '__new__', > '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', > '__sizeof__', '__str__', '__subclasshook__', '__weakref__', > '_field_cache', '_field_name_cache', '_fields', '_fill_fields_cache', > '_fill_m2m_cache', '_fill_related_many_to_many_cache', > '_fill_related_objects_cache', '_join_cache', '_m2m_cache', > '_many_to_many', '_prepare', 'abstract', 'abstract_managers', > 'add_field', 'add_virtual_field', 'admin', 'app_label', > 'auto_created', 'auto_field', 'concrete_managers', > 'contribute_to_class', 'db_table', 'db_tablespace', > 'duplicate_targets', 'fields', 'get_add_permission', > 'get_all_field_names', 'get_all_related_m2m_objects_with_model', > 'get_all_related_many_to_many_objects', 'get_all_related_objects', > 'get_all_related_objects_with_model', 'get_ancestor_link', > 'get_base_chain', 'get_change_permission', 'get_delete_permission', > 'get_field', 'get_field_by_name', 'get_fields_with_model', > 'get_latest_by', 'get_m2m_with_model', 'get_ordered_objects', > 'get_parent_list', 'has_auto_field', 'init_name_map', 'installed', > 'local_fields', 'local_many_to_many', 'managed', 'many_to_many', > 'module_name', 'object_name', 'order_with_respect_to', 'ordering', > 'parents', 'permissions', 'pk', 'pk_index', 'proxy', > 'proxy_for_model', 'setup_pk', 'setup_proxy', 'unique_together', > 'verbose_name', 'verbose_name_plural', 'verbose_name_raw', > 'virtual_fields']>>> qs.model._meta.get_field('name') > > <django.db.models.fields.CharField object at 0x842c60c>>>> > type(qs.model._meta.get_field('name')) > > <class 'django.db.models.fields.CharField'> > > HTH
-- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.