No worries 👍

Sent from Outlook Mobile<https://aka.ms/blhgte>

________________________________
From: django-developers@googlegroups.com <django-developers@googlegroups.com> 
on behalf of Florian Apolloner <f.apollo...@gmail.com>
Sent: Tuesday, June 16, 2020 7:40:56 PM
To: Django developers (Contributions to Django itself) 
<django-developers@googlegroups.com>
Subject: Re: Overriding template blocks without copy/pasting entire template 
files

Ah, might be that you got hold up in a moderation queue or similar. Google 
groups is weird sometimes -- sorry!

On Tuesday, June 16, 2020 at 3:20:25 PM UTC+2, Arvind Nedumaran wrote:
Something must be faulty with my email delivery I suppose. I sent that email a 
good 8 hours ago. :)

Onward,
Arvind

Sent from Outlook Mobile<https://aka.ms/blhgte>

________________________________
From: django-d...@googlegroups.com <django-d...@googlegroups.com> on behalf of 
Florian Apolloner <f.apo...@gmail.com>
Sent: Tuesday, June 16, 2020 6:46:45 PM
To: Django developers (Contributions to Django itself) 
<django-d...@googlegroups.com>
Subject: Re: Overriding template blocks without copy/pasting entire template 
files

If you look at the mails beyond the first one, you will see that Josh & Carlton 
already came to that conlusion ;)

On Tuesday, June 16, 2020 at 2:16:31 PM UTC+2, Arvind Nedumaran wrote:
Could you elaborate on how this is different from extending a base template and 
re-defining the necessary blocks?

#base.html
{% block title %}{{ section.title }}{% endblock %}
.....

{% extends "base.html" %}
{% block title %} My custom title that isn't section.title {% endblock %}
....

This much is already possible right?


On Tue, Jun 16, 2020 at 10:34 AM Josh Smeaton <josh....@gmail.com> wrote:
Something that has bugged me for awhile is the requirement to copy and paste an 
entire template when you would just like to override a single block. This 
arises mostly when overriding admin templates, like `admin/base.html`.

In my ideal world, I'd be able to do something like this:

    # myapp/templates/admin/base.html
    {% override "admin/base.html" %}
    {% block footer %}this site is restricted, blah blah legal text blah{% 
endblock %}


And then the template loading system would find the next `admin/base.html` in 
the chain and use my overrides.

There is prior art too. https://pypi.org/project/django-apptemplates/ allows 
you to override a template from a specific app using this syntax:

    # myapp/templates/admin/base.html
    {% extends "admin:admin/base.html" %}
    {% block footer %}this site is restricted, blah blah legal text blah{% 
endblock %}


I think this kind of functionality should be included within Django itself. If 
others agree, should there be a new name such as override, or would overloading 
extends be good enough?

--
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 django-d...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/6cf43971-1ea9-4b93-9a35-aaab5908327co%40googlegroups.com<https://groups.google.com/d/msgid/django-developers/6cf43971-1ea9-4b93-9a35-aaab5908327co%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
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 django-d...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/89b8d89a-d7e4-44fa-a5b8-cb8e1c910785o%40googlegroups.com<https://groups.google.com/d/msgid/django-developers/89b8d89a-d7e4-44fa-a5b8-cb8e1c910785o%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
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 
django-developers+unsubscr...@googlegroups.com<mailto:django-developers+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/a357fb57-55b3-4f65-bf59-cf64c3e412bbo%40googlegroups.com<https://groups.google.com/d/msgid/django-developers/a357fb57-55b3-4f65-bf59-cf64c3e412bbo%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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 django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/BYAPR14MB291880739C1BB3E52F821C18A39D0%40BYAPR14MB2918.namprd14.prod.outlook.com.

Reply via email to