C# “is” operator – is that reflection?

Referencing ECMA-335, the is operator generates the isinst object model IL instruction (Partition III §4.6), which is part of the base instruction set as opposed to being part of the Reflection library (Partition IV §5.5). Edit: The is operator is extremely efficient compared to the reflection library. You could perform basically the same test much … Read more

How to introspect django model fields?

You can use model’s _meta attribute to get field object and from field you can get relationship and much more e.g. consider a employee table which has a foreign key to a department table In [1]: from django.db import models In [2]: model = models.get_model(‘timeapp’, ‘Employee’) In [3]: dep_field = model._meta.get_field_by_name(‘department’) In [4]: dep_field[0].target_field Out[4]: … Read more