257 | | app_list.append({ |
258 | | 'name': app_label.title(), |
259 | | 'has_module_perms': has_module_perms, |
260 | | 'models': [model_dict], |
261 | | }) |
| 257 | |
| 258 | existing_app = False |
| 259 | for app in app_list: |
| 260 | if app['name'] == app_label.title(): |
| 261 | app['models'].append(model_dict) |
| 262 | existing_app = True |
| 263 | if not existing_app: |
| 264 | app_list.append({ |
| 265 | 'name': app_label.title(), |
| 266 | 'has_module_perms': has_module_perms, |
| 267 | 'models': [model_dict], |
| 268 | }) |
| 269 | |
| 270 | # Sort apps and models |
| 271 | app_list.sort(lambda x, y: cmp(x['name'], y['name'])) |
| 272 | for app in app_list: |
| 273 | app['models'].sort(lambda x, y: cmp(x['name'], y['name'])) |
| 274 | |