Yes, i know i can pass data (variables) from view to template. But my
question is, if i have report, for example with headline "This month" and
same report for previous with headline "Previous month", if i can such
things solve directly in template, based on view which is calling template.
I don't like the way to put texts into template just to be specific for
view.
But thanks for answer, it's django-way and i have to respect it :/
Dne středa 2. listopadu 2016 20:28:22 UTC+1 Lekan Wahab napsal(a):
>
> Hi,
> I'm not sure I completely understand what you need but if I do, I think
> passing different contexts to the same template would help you achieve
> that.
>
> You could easily have something like :
>
> def initial_view(request) :
> variableone = 'a'
> variabletwo = 'b'
> return response(yourtemplate, {'a':variableone, 'b' :variabletwo})
>
> Then you can also have another view using the same template but with
> different contexts.
> Something like,
>
> def final_view(request) :
> variableone = 'c'
> variabletwo = 'd'
> return response(yourtemplate, {'c':variableone, 'd' :variabletwo})
>
> Also, if you have a repetitive section in your template, you could just
> write it once and use the {% include %} tag to use it in each of your other
> templates.
>
> I hope that helps.
>
> Lekan.
> Python is the "most powerful language you can still read".
>
> On 2 Nov 2016 19:48, "Moreplavec" <[email protected] <javascript:>>
> wrote:
>
> Greetings,
>
> i'm creating template for simple table report. Data shown are for current
> month. Than i realised i need same report for previous month. I can copy
> created template and modify texts, but i don't like. Is it possible to use
> same template for more views and only controll differences based on view,
> which is template calling? For example, i need to show "Current month" or
> "Previous month". I can put these texts into variable, but i hope there is
> better way to controll directly in template.
>
> Please, can you help me or point me to some good article? Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected]
> <javascript:>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a61a7a9d-06a2-4749-bf71-f6d2351396af%40googlegroups.com
>
> <https://groups.google.com/d/msgid/django-users/a61a7a9d-06a2-4749-bf71-f6d2351396af%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/08ec103b-8f35-414e-9c94-a3ee5e398cc5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.