Additional context for class based views through urlconf

I thought there was a simpler method of adding context through the urlconf but after having a look at the source this is what I came up with. Apparently there's only getcontextdata() so I used a lambda to add what I needed.

Update: I should probably have used extra_context={'model': 'Frontpage'}

Raw
url(  
    r'^$',
    TemplateView.as_view(
        template_name='pages/front.html',
        get_context_data=lambda: {'model': 'Frontpage'},
    ),    
    name='front',
),

1 comment

  1. avatar
    wrote this comment on
    Thank you!

Reply

Cancel reply
Markdown. Syntax highlighting with <code lang="php"><?php echo "Hello, world!"; ?></code> etc.
DjangoPythonBitcoinTuxDebianHTML5 badgeSaltStackUpset confused bugMoneyHackerUpset confused bugX.OrggitFirefoxWindowMakerBashIs it worth the time?i3 window managerWagtailContainerIrssiNginxSilenceUse a maskWorldInternet securityPianoFontGnuPGThunderbirdJenkinshome-assistant-logo