SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 17cedceb authored by George Katsikas's avatar George Katsikas :goat:
Browse files

prevent crash when creating new journal

parent 488feff8
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,11 @@ class JournalAdmin(admin.ModelAdmin): ...@@ -50,7 +50,11 @@ class JournalAdmin(admin.ModelAdmin):
# - that are active # - that are active
def formfield_for_manytomany(self, db_field, request, **kwargs): def formfield_for_manytomany(self, db_field, request, **kwargs):
if db_field.name == "alternative_journals": if db_field.name == "alternative_journals":
journal_id = request.resolver_match.kwargs["object_id"] journal_id = request.resolver_match.kwargs.get("object_id")
if journal_id is None:
return super().formfield_for_manytomany(db_field, request, **kwargs)
journal = Journal.objects.get(pk=journal_id) journal = Journal.objects.get(pk=journal_id)
selections = Journal.objects.filter(name="SciPost Selections") selections = Journal.objects.filter(name="SciPost Selections")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment