Mc-
Mc-

Reputation: 4056

Calling html from template

I'm bulding a website in Django 1.3

One of my views is a complex HTML that repeats a lot ( an image gallery with some nested s )

Is there a way to put that logic in a separate file? and call it from django?

Note: Maybe there is a way to do this in HTML and this question may not be related to django. Note2: I found this other thread which was about calling django's function from a template, using this maybe I could use "render_to_response" function to load the inner HTML.

The purpose of this is to have separated logics for different components.

Upvotes: 0

Views: 117

Answers (2)

arie
arie

Reputation: 18982

Maybe there is a way to do this in HTML

If you just want to split your HTML into seperate files and chunks you should use the {% include %} tag Dougal mentioned. However, if you want to include extra logic in your HTML you should turn to Template Tags and Filters:

Django’s template system comes with a wide variety of built-in tags and filters designed to address the presentation logic needs of your application. Nevertheless, you may find yourself needing functionality that is not covered by the core set of template primitives. You can extend the template engine by defining custom tags and filters using Python, and then make them available to your templates using the {% load %} tag.

Upvotes: 0

Danica
Danica

Reputation: 28856

If you want to pull the django template code out into a separate file, take a look at the {% include %} tag.

(It seems like you might be asking about something else, but then I'm not real clear on what you want to do...)

Upvotes: 3

Related Questions