Django uses Python modules instead of classes. The problem is how to
avoid duplication of the code in controllers when I want to put some
data to parent templates? Let see the example:
base.html:
{% block welcome %}
Hello {{ name }}!
{% endblock %}
{% block main %}{% endblock %}
test1.html:
{% extends "base.html" %}
{% block main %}blah, blah{% endblock %}
test2.html:
{% extends "base.html" %}
{% block main %}different blah, blah{% endblock %}
How to deal with the same, shared blocks? Do I have to copy code for
all shared blocks? It looks very bad.
views.py:
def test(request):
return render_to_response('test.html', {'name':'Jarek'})
def test2(request):
return render_to_response('test2.html', {'name':'Jarek'})
I would like to have something like RoR, where all shared variables for
all shared (partials) templates can be set in one, and only one, place:
application.rb:
class Application
before_filter :defaults
def defaults
@name = 'Jarek'
end
end
test1_controller.rb
class Test1 < Application
def index
end
end
test2_controller.rb:
class Test2 < Application
def index
end
end
--
Jaroslaw Zabiello
http://blog.zabiello.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---