At this point it’s probably easiest for Django to provide templates only for Javascript front-end, and for Django to only serve API endpoints.
We really don’t need Django to serve HTML pages anymore, except for the initial page-load. I believe this is where the web is headed for the long-term. It may be possible to develop a Python syntax that analogous to HTML templates, with Django translating that for Javascript templating. Now, whether Django serves these templates in Angular/Ember/React/whatever or develop some new framework (or even new HTML standards that operates on APIs directly...), is another question. -bobby > On Jun 1, 2015, at 12:08 PM, Javier Guerra Giraldez <[email protected]> > wrote: > > On Sun, May 31, 2015 at 5:21 PM, Emil Stenström <[email protected]> wrote: >> Are you saying you prefer implementing all templates in two languages, since >> implementing views twice is too much work? The time you save being able to >> reuse the same templates in the client side is huge, and avoids the >> maintenance burden of keeping two identical things in sync. >> >> I'm also not saying you should implement views twice. Each time you click a >> link that request can go to the exact same server side view, get the correct >> data back (only the data), and re-render only the parts that changed. >> >>> >>> Also the need to reimplement django.shortcuts.render is unneded. Add in >>> the base tpl a {% if request.is_ajax %} then wrap the result in a entire >>> html tpl for regular http calls and the new content only in the other case. >> >> >> I'm not sure I follow here. Are you saying I should just go through all my >> templates and split them in two? What do you mean by "new content" here? My >> suggestion is that you would send only the new DATA, and that the client >> would use that data, and the templates, to re-render the page. > > > first advice when discussing things on the internet: don't take it personal. > > I think that Enrique means that having "the same" template language is > a non-goal. the "cognitive burden" of two languages is not so heavy; > and since these two environments are so different, there would be > different considerations that make some features unpractical on one > side or the other; or maybe some choice could be "the best" on one and > too awkward or badly supported on the other. > > personally, i mostly agree: i do use templating on JS, and it doesn't > look at all like Django templates. That means sometimes i render some > things in the server, other things in the front end, and a few things > (very few) on both, leading to mostly duplicate code. would it be > nice to have some code that works equally well on either side? yes, > but it's a relatively small gain. > > if "using the same language" was so important, we would all be using > node.js... > > -- > Javier > > -- > You received this message because you are subscribed to the Google Groups > "Django developers (Contributions to Django itself)" 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 http://groups.google.com/group/django-developers. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/CAFkDaoSOYOoyX0w_m0ERzhiJmVPXWGr6pB29AongesG43gOw1w%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" 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 http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/77987679-053A-452B-98B1-920B6D09263A%40gmail.com. For more options, visit https://groups.google.com/d/optout.
