1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 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
|
More like this
- ContentType Form by nosrednakram 3 years, 8 months ago
- RFC: Shim to allow view classes rather than functions by peterbraden 4 years, 2 months ago
- Comma Seprated Character Field to store Geographic Coordinates by vijay.shanker 5 months, 1 week ago
- Application Name DatabaseRouter by kraiz 7 months, 2 weeks ago
- db_dump.py - for dumpping and loading data from database by limodou 6 years, 3 months ago
Comments
Use the Power, Luke!
#