Skip to content

Instantly share code, notes, and snippets.

@daimon99
Created April 15, 2020 03:53
Show Gist options
  • Save daimon99/7e42b2d6767f3e136bb3680cb0c25436 to your computer and use it in GitHub Desktop.
Save daimon99/7e42b2d6767f3e136bb3680cb0c25436 to your computer and use it in GitHub Desktop.
Django admin 新建记录页面表单初始值 / Django admin add form initial value
def get_changeform_initial_data(self, request):
init = super().get_changeform_initial_data(request)
init['company'] = get_user_last_company(request.user)
return init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment