django-bakery icon indicating copy to clipboard operation
django-bakery copied to clipboard

page parameters

Open eddyizm opened this issue 5 years ago • 1 comments

I've been reading the docs and have been able to mostly bake a site successfully. However I'm having an issue on passing page parameters to the baking view.

Original View that works in the regular runserver command

class auto(View):
    def get(self, request):
        return render(
        request,
        'app/auto.html',
        {
            'title':'Auto Insurance',
            'message': 'generic message',
            'year':datetime.now().year,
        }
        )

I use this bakery view

class AutoTemplateView(BuildableTemplateView):
    build_path = 'auto.html'
    template_name = 'app/auto.html'

The settings has the view and the page is being generated successfully outside of the title and message are blank

BAKERY_VIEWS = (
    'app.views.HomeTemplateView',
    'app.views.AutoTemplateView',
)

html template

      <div class="col-sm-8 col-sm-offset-2">
            <h3 class="title-one"> {{ title }}</h3>
              <h4>{{ message }}</h4>
         </div>

and bakery html output :

<div class="col-sm-8 col-sm-offset-2">
            <h3 class="title-one"> </h3>
              <h4></h4>
         </div>

I can't imagine this is an actual bug but what am I missing?

eddyizm avatar Sep 13 '20 18:09 eddyizm

check the get_context_data method.

`

def get_context_data(self, **kwargs):
    context = super().get_context_data(**kwargs)
    context["title"] = "Auto Insurance"
    context["message"] = "generic message"
    context["year"] = datetime.now().year
    
    return context

`

YusufBilgin avatar Sep 20 '24 11:09 YusufBilgin