As in django, make any textual information available in the template.



  • Like, Django Do you want any text information in the template?

    Like, I have a few pages. Main and about us.♪ The page should include several blocks of textual information that can be edited through the Adminka.

    The number of blocks is fixed and different for each page.

    Modelling isn't right here. Please.



  • The simplest and most obvious way is to keep the template in the database. Create a model, in the simplest case, containing a text field and the name of.

    from django.template import Template
    from myapp.models import DbTmpl
    

    a = DbTmpl.objects.get(name='contacts').html
    tmpl = Template(a)
    tmpl.render({'phone' : '111-22-33', 'city' : 'Moscow'})

    It's up to the task and the fantasy.
    In addition, for such cases, there is a battery: http://django-dbtemplates.readthedocs.org/en/latest/


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2