Showing posts with label django. Show all posts
Showing posts with label django. Show all posts

Saturday, November 15, 2014

Prepopulate a `user` field in a Django admin form

It took me a while to find the solution, which I am posting here:
class ArticleAdmin(admin.ModelAdmin):

    form = ArticleAdminForm

    def get_changeform_initial_data(self, request):
        initial = super().get_changeform_initial_data(request)
        initial['submitted_by'] = request.user
        return initial


Saturday, April 19, 2014

A Scenic Drive through the Django Request-Response Cycle

PyCon US 2014, Dan Langer:

A simple "Hello World!" page, served via Django, passes though a surprising number of layers & components. For a newcomer to the language or the platform, this can be overwhelming at the start. Here I'll take you on a drive through Django's request-response cycle, focusing on using its layered model to understand what's going on and get things done.