Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

page parameters #147

Open
eddyizm opened this issue Sep 13, 2020 · 1 comment
Open

page parameters #147

eddyizm opened this issue Sep 13, 2020 · 1 comment

Comments

@eddyizm
Copy link

eddyizm commented Sep 13, 2020

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?

@YusufBilgin
Copy link

YusufBilgin commented Sep 20, 2024

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

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants