from django.contrib.contenttypes.models import ContentType class GetAllModels(object): ''' an iterator function to produce model names installed as choices format ''' def __init__(self,counter=0): self.counter = counter def __iter__(self): return self def next(self): ct = ContentType.objects.all() if self.counter < len(ct)-1 : self.counter = self.counter +1 return (ct[self.counter].app_label, ct[self.counter].model) else: raise StopIteration