INNER CODE UNIT · Python

to_dict

eamigo86/graphene-django-extras · graphene_django_extras/base_types.py:92

    def to_dict(self):
        """Convert the object to a dictionary."""
        return {
            self.results_field_name: [e.to_dict() for e in self.results],
            "count": self.count,
        }


def resolver(attr_name, root, instance, info):
    """Resolve generic foreign key attributes."""
    if attr_name == "app_label":
        return instance._meta.app_label
    elif attr_name == "id":
        return instance.id
    elif attr_name == "model_name":
        return instance._meta.model.__name__

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…