How can I access request object in the wagtail Page model?
问题 I wanna dynamically set default value of the field to the currently logged in user: class SimplePage(Page): author = models.CharField(max_length=255, default=request.user) I know about get_context , but class attributes cannot call instance methods. def get_context(self, request, *args, **kwargs): return { PAGE_TEMPLATE_VAR: self, 'self': self, 'request': request, } Any more ideas? Essentially whoever is logged in into the admin should become author's default. 回答1: I got part way there but am