Skip to content

Commit

Permalink
Merge pull request #309 from maykinmedia/issue/fix-permissions-form
Browse files Browse the repository at this point in the history
🐛 Initial token value set on Permission admin
  • Loading branch information
Viicos authored Aug 22, 2022
2 parents 276d5d9 + 737da04 commit 31c7921
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/objects/token/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def get_form_data(self, request, object_id) -> dict:
if request.method == "POST":
form = ModelForm(request.POST, request.FILES, instance=obj)
else:
form = ModelForm(instance=obj)
form = ModelForm(
instance=obj, initial={"token_auth": request.GET.get("token_auth")}
)
form.is_valid()

values = {field.name: field.value() for field in form}
Expand Down Expand Up @@ -101,6 +103,7 @@ def add_view(self, request, form_url="", extra_context=None):

class PermissionInline(EditInlineAdminMixin, admin.TabularInline):
model = Permission
fk_name = "token_auth"
fields = ("object_type", "mode", "use_fields", "fields")


Expand Down

0 comments on commit 31c7921

Please sign in to comment.