code: def is_restricted(self):
          
          return (
              not hasattr(self.choices, 'queryset') or
              self.choices.queryset.count() > settings.FOREIGN_KEY_MAX_SELECBOX_ENTRIES
          )
docs: Returns True or False according to number of objects in queryset.
          If queryset contains too much objects the widget will be restricted and won't be used select box with choices.