| 151 | def make_app_names(): |
| 152 | try: |
| 153 | tmp_file=open('./templates/app_names.html','w') |
| 154 | except IOError: |
| 155 | return False |
| 156 | app_names=set() |
| 157 | path=os.path.split(os.getcwd()) |
| 158 | sys.path.insert(0,path[0]) |
| 159 | os.environ["DJANGO_SETTINGS_MODULE"]=path[1]+'.settings' |
| 160 | settings._import_settings() |
| 161 | from django.db.models import get_models |
| 162 | for m in get_models(): app_names.add(m._meta.app_label.title()) |
| 163 | p1,p2='\"%}','{% trans \"' |
| 164 | tmp_file.write(p2+(p1+p2).join(app_names)+p1) |
| 165 | tmp_file.close() |
| 166 | os.environ["DJANGO_SETTINGS_MODULE"]='' |
| 167 | return tmp_file |
| 168 | |