diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-07-20 12:25:14 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-07-20 12:25:14 (GMT) |
commit | 8b02218b9c1f524d37e2a20a613a7301a7aa7689 (patch) | |
tree | 117a06507f26b038bdaa704109c6226a04c3d508 | |
parent | 4313274eeb823448a156cf7891d6eb64efe67c13 (diff) | |
parent | cb7893dd84f84549eadea316c7cd3faf68e5488b (diff) |
Merge branch 'master' into stable
-rw-r--r-- | program/admin.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/program/admin.py b/program/admin.py index 665ece2..d871e16 100644 --- a/program/admin.py +++ b/program/admin.py @@ -107,6 +107,17 @@ class ShowAdmin(admin.ModelAdmin): 'musicfocus', ) + def formfield_for_foreignkey(self, db_field, request=None, **kwargs): + try: + show_id = int(request.get_full_path().split('/')[-2]) + except ValueError: + show_id = None + + if db_field.name == 'predecessor' and show_id: + kwargs['queryset'] = Show.objects.exclude(pk=show_id) + + return super(ShowAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) + admin.site.register(BroadcastFormat, BroadcastFormatAdmin) admin.site.register(MusicFocus, MusicFocusAdmin) admin.site.register(ShowInformation, ShowInformationAdmin) |