Auto-populating created_by field with Django admin site

前端 未结 3 1422
梦谈多话
梦谈多话 2020-12-12 23:04

I want to use the Django admin interface for a very simple web application but I can\'t get around a problem that should not be that hard to resolve ..

Consider the

相关标签:
3条回答
  • 2020-12-12 23:30

    You need to specify a default for the field, in this case a method call that gets the current user (see the auth documentation to get the current user).

    0 讨论(0)
  • 2020-12-12 23:34

    http://code.djangoproject.com/wiki/CookBookNewformsAdminAndUser

    Involves implementing save methods on your ModelAdmin objects.

    0 讨论(0)
  • 2020-12-12 23:40

    I really wanted a better solution than the ones I found elsewhere, so I wrote some middleware - implementation on the Populate user Id question. My solution requires no changes to any form or view.

    0 讨论(0)
提交回复
热议问题