analytical_prat
analytical_prat

Reputation: 979

Django project, pure javascript, html and template tags best practices

I am new to developing a website and because of my familiarity with Python and considering the complexity of the website, I chose Django.

I want to know the best practice for developing a template through the Django framework. My question is two-fold.

  1. Is it best to have a bunch of for loops / if statements in the template using template tags and other features of Django?
  2. Or is it passing the variables from Django to Javascript through JSON and then loading the page asynchronously?

For the first, I found the following merits: its fairly easy. I know what I want, I code the loops and I get the result that I expect. Plus giving IDs / names to HTML tags is super simple. Inline scripting also becomes simple, but I personally dont like it. But as objects start to get high in number, page load speed suffers.

For the second, and I am very new to this, the ease is gone. There is, I feel, another hoop to jump through Javascript, with JSON parsing and then the actual modeling.

If not either first or second, may be there is a balance between the two? All help is appreciated.

Upvotes: 1

Views: 176

Answers (1)

Irfan wani
Irfan wani

Reputation: 5075

If i got your question correctly then i think the answer is AJAX i.e, using the same page to load different content.You don't have to go to another page but on the same page, setting some links, you can pull newer data without loading a new page. Hope this helped you!

Upvotes: 1

Related Questions