diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-07-20 12:21:39 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-07-20 12:21:39 (GMT) |
commit | cb7893dd84f84549eadea316c7cd3faf68e5488b (patch) | |
tree | 117a06507f26b038bdaa704109c6226a04c3d508 /program | |
parent | 43889586f9d4be5939b45cd0360081642f5aebb6 (diff) | |
parent | d2ddec17ac196c2a090875d081757d195b5190e1 (diff) |
Merge branch 'predecessor-selection'
Diffstat (limited to 'program')
-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) |